Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

[nest] Allow setting setpoints with decimals #3950

Merged
merged 1 commit into from
Feb 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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