@@ -804,6 +804,74 @@ const colorControl = {
804804 events : [ ] ,
805805} ;
806806
807+ const thermostat = {
808+ '@context' : 'https://iot.mozilla.org/schemas' ,
809+ '@type' : [ 'Thermostat' , 'TemperatureSensor' ] ,
810+ name : 'Virtual Thermostat' ,
811+ properties : [
812+ {
813+ name : 'temperature' ,
814+ value : 20 ,
815+ metadata : {
816+ title : 'Temperature' ,
817+ type : 'number' ,
818+ '@type' : 'TemperatureProperty' ,
819+ unit : 'degree celsius' ,
820+ minimum : 0 ,
821+ maximum : 100 ,
822+ readOnly : true ,
823+ } ,
824+ } ,
825+ {
826+ name : 'heatingTargetTemperature' ,
827+ value : 19 ,
828+ metadata : {
829+ title : 'Heating Target' ,
830+ type : 'number' ,
831+ '@type' : 'TargetTemperatureProperty' ,
832+ unit : 'degree celsius' ,
833+ minimum : 10 ,
834+ maximum : 38 ,
835+ } ,
836+ } ,
837+ {
838+ name : 'coolingTargetTemperature' ,
839+ value : 25 ,
840+ metadata : {
841+ title : 'Cooling Target' ,
842+ type : 'number' ,
843+ '@type' : 'TargetTemperatureProperty' ,
844+ unit : 'degree celsius' ,
845+ minimum : 10 ,
846+ maximum : 38 ,
847+ } ,
848+ } ,
849+ {
850+ name : 'heatingCooling' ,
851+ value : 'heating' ,
852+ metadata : {
853+ title : 'Heating/Cooling' ,
854+ type : 'string' ,
855+ '@type' : 'HeatingCoolingProperty' ,
856+ enum : [ 'off' , 'heating' , 'cooling' ] ,
857+ readOnly : true ,
858+ } ,
859+ } ,
860+ {
861+ name : 'thermostatMode' ,
862+ value : 'heat' ,
863+ metadata : {
864+ title : 'Mode' ,
865+ type : 'string' ,
866+ '@type' : 'ThermostatModeProperty' ,
867+ enum : [ 'off' , 'heat' , 'cool' , 'auto' ] ,
868+ } ,
869+ } ,
870+ ] ,
871+ actions : [ ] ,
872+ events : [ ] ,
873+ } ;
874+
807875if ( ffmpegMajor !== null && ffmpegMajor >= 4 ) {
808876 videoCamera . properties [ 0 ] . metadata . links . push ( {
809877 rel : 'alternate' ,
@@ -837,6 +905,7 @@ const VIRTUAL_THINGS = [
837905 alarm ,
838906 energyMonitor ,
839907 colorControl ,
908+ thermostat ,
840909] ;
841910
842911/**
@@ -905,6 +974,16 @@ class VirtualThingsProperty extends Property {
905974 } else {
906975 this . device . adapter . stopTranscode ( ) ;
907976 }
977+ } else if ( this . name == 'thermostatMode' ) {
978+ const heatingCooling = this . device . properties . get ( 'heatingCooling' ) ;
979+
980+ if ( this . value === 'heat' ) {
981+ heatingCooling . setCachedValueAndNotify ( 'heating' ) ;
982+ } else if ( this . value === 'cool' ) {
983+ heatingCooling . setCachedValueAndNotify ( 'cooling' ) ;
984+ } else if ( this . value === 'off' ) {
985+ heatingCooling . setCachedValueAndNotify ( 'off' ) ;
986+ }
908987 }
909988
910989 resolve ( this . value ) ;
0 commit comments