Skip to content

Commit

Permalink
Merge pull request openhab#3950 from watou/nest-fix-3944
Browse files Browse the repository at this point in the history
[nest] Allow setting setpoints with decimals
  • Loading branch information
kaikreuzer committed Feb 1, 2016
2 parents df45d18 + c8958fd commit fbd40dc
Showing 1 changed file with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.util.Date;
import java.util.HashMap;
Expand Down Expand Up @@ -120,6 +121,17 @@ public Object convert(Class type, Object value) {
}
}
}, ColorState.class);
convertUtils.register(new Converter() {
@SuppressWarnings("rawtypes")
@Override
public Object convert(Class type, Object value) {
if (value instanceof DecimalType) {
return ((DecimalType) value).toBigDecimal();
} else {
return null;
}
}
}, BigDecimal.class);
convertUtils.register(new Converter() {
@SuppressWarnings("rawtypes")
@Override
Expand Down Expand Up @@ -195,7 +207,7 @@ public void setThermostats_by_id(Map<String, Thermostat> thermostats_by_id) {

/**
* Return the thermostats map, mapped by name.
*
*
* @return the thermostats_by_name;
*/
@JsonIgnore
Expand Down Expand Up @@ -324,7 +336,7 @@ public String getKey(String expression) {

/**
* Return a JavaBean property by name.
*
*
* @param name
* the named property to return
* @return the named property's value
Expand All @@ -345,7 +357,7 @@ public Object getProperty(String name)
/**
* Set the specified property value, performing type conversions as required to conform to the type of the
* destination property.
*
*
* @param name
* property name (can be nested/indexed/mapped/combo)
* @param value
Expand Down Expand Up @@ -379,7 +391,7 @@ public void setDevices(Devices devices) {

/**
* Convenience method so property specs don't have to include "devices." in each one.
*
*
* @return name-based map of thermostats
*/
@JsonIgnore
Expand All @@ -389,7 +401,7 @@ public Map<String, Thermostat> getThermostats() {

/**
* Convenience method so property specs don't have to include "devices." in each one.
*
*
* @return name-based map of smoke_co_alarms
*/
@JsonIgnore
Expand All @@ -399,7 +411,7 @@ public Map<String, SmokeCOAlarm> getSmoke_co_alarms() {

/**
* Convenience method so property specs don't have to include "devices." in each one.
*
*
* @return name-based map of cameras
*/
@JsonIgnore
Expand Down Expand Up @@ -475,7 +487,7 @@ public void sync() {
* This method returns a new data model containing only the affected Structure, Thermostat, SmokeCOAlarm or Camera,
* and only the property of the bean that was changed. This new DataModel object can be sent to the Nest API in
* order to perform an update via HTTP PUT.
*
*
* @param property
* the property to change
* @param newState
Expand Down Expand Up @@ -562,7 +574,7 @@ public DataModel updateDataModel(String property, Object newState)

/**
* Lastly, set the property into the update data model
*
*
* TODO: cannot update a binding string of the form "=[structures(Name).thermostats(Name).X]" or
* "=[structures(Name).smoke_co_alarms(Name).X]" because the name-based map of structures is not present in the
* updateDataModel
Expand Down

0 comments on commit fbd40dc

Please sign in to comment.