10
10
11
11
import java .io .UnsupportedEncodingException ;
12
12
import java .lang .reflect .InvocationTargetException ;
13
+ import java .math .BigDecimal ;
13
14
import java .net .URLDecoder ;
14
15
import java .util .Date ;
15
16
import java .util .HashMap ;
@@ -120,6 +121,17 @@ public Object convert(Class type, Object value) {
120
121
}
121
122
}
122
123
}, ColorState .class );
124
+ convertUtils .register (new Converter () {
125
+ @ SuppressWarnings ("rawtypes" )
126
+ @ Override
127
+ public Object convert (Class type , Object value ) {
128
+ if (value instanceof DecimalType ) {
129
+ return ((DecimalType ) value ).toBigDecimal ();
130
+ } else {
131
+ return null ;
132
+ }
133
+ }
134
+ }, BigDecimal .class );
123
135
convertUtils .register (new Converter () {
124
136
@ SuppressWarnings ("rawtypes" )
125
137
@ Override
@@ -195,7 +207,7 @@ public void setThermostats_by_id(Map<String, Thermostat> thermostats_by_id) {
195
207
196
208
/**
197
209
* Return the thermostats map, mapped by name.
198
- *
210
+ *
199
211
* @return the thermostats_by_name;
200
212
*/
201
213
@ JsonIgnore
@@ -324,7 +336,7 @@ public String getKey(String expression) {
324
336
325
337
/**
326
338
* Return a JavaBean property by name.
327
- *
339
+ *
328
340
* @param name
329
341
* the named property to return
330
342
* @return the named property's value
@@ -345,7 +357,7 @@ public Object getProperty(String name)
345
357
/**
346
358
* Set the specified property value, performing type conversions as required to conform to the type of the
347
359
* destination property.
348
- *
360
+ *
349
361
* @param name
350
362
* property name (can be nested/indexed/mapped/combo)
351
363
* @param value
@@ -379,7 +391,7 @@ public void setDevices(Devices devices) {
379
391
380
392
/**
381
393
* Convenience method so property specs don't have to include "devices." in each one.
382
- *
394
+ *
383
395
* @return name-based map of thermostats
384
396
*/
385
397
@ JsonIgnore
@@ -389,7 +401,7 @@ public Map<String, Thermostat> getThermostats() {
389
401
390
402
/**
391
403
* Convenience method so property specs don't have to include "devices." in each one.
392
- *
404
+ *
393
405
* @return name-based map of smoke_co_alarms
394
406
*/
395
407
@ JsonIgnore
@@ -399,7 +411,7 @@ public Map<String, SmokeCOAlarm> getSmoke_co_alarms() {
399
411
400
412
/**
401
413
* Convenience method so property specs don't have to include "devices." in each one.
402
- *
414
+ *
403
415
* @return name-based map of cameras
404
416
*/
405
417
@ JsonIgnore
@@ -475,7 +487,7 @@ public void sync() {
475
487
* This method returns a new data model containing only the affected Structure, Thermostat, SmokeCOAlarm or Camera,
476
488
* and only the property of the bean that was changed. This new DataModel object can be sent to the Nest API in
477
489
* order to perform an update via HTTP PUT.
478
- *
490
+ *
479
491
* @param property
480
492
* the property to change
481
493
* @param newState
@@ -562,7 +574,7 @@ public DataModel updateDataModel(String property, Object newState)
562
574
563
575
/**
564
576
* Lastly, set the property into the update data model
565
- *
577
+ *
566
578
* TODO: cannot update a binding string of the form "=[structures(Name).thermostats(Name).X]" or
567
579
* "=[structures(Name).smoke_co_alarms(Name).X]" because the name-based map of structures is not present in the
568
580
* updateDataModel
0 commit comments