Energy Usage Tech Info
The tracking of energy usage for climate is handled in the Climate Plugin device. All other devices are handled with the Lighting Plugin device. The energy usage of a device is stored in the device data 285 (Wattage). For climate devices it is a comma separated list of power consumption when the unit is in COOL, HEAT, and FAN_ONLY. The access point calculates the peak and average for each hour from :30 before and past. and reports this hourly. For example, the access point will report at 9:30 the average/peak usage for the "9:00", which is calculated based on data from 8:30 - 9:30. The device data #286 Energy Log is used internally to collect this information as a comma separated list of current consumption (watts), average since last reading, peak since last reading, unix_timestamp of last reading, number of seconds in average.
The energy usage is only an estimate based on the 'Wattage' device data. Leave this blank and the energy will not be auto-calculated. Devices which know how to report energy usage directly should leave Wattage blank and instead fire the event EVENT_Energy_Consumption_CONST with the current consumption in watts.
Each hour, before reporting, the access point checks to see if the list of rooms/devices has changed. If it has, it calls: https://controlmyhouse.net/report_energy_device_room.php with the following post data:
PK_AccessPoint,Username,Password identify this access point. PK_Device_xxx for each device where xxx is the device id and the value is Room, DeviceTemplate, DeviceCategory, Description. PK_Room_xxx where xxx is the room id and the value is the Room Description.
It then calls https://controlmyhouse.net/report_energy_log.php with the same PK_AccessPoint,Username,Password. Also Time = the current date/time being reported. And PK_Device_xxx where xxx is the device id and the value is Average Consumption, Peak Consumption, in watts.
Those 2 php files store the data in the database cmh_energy. The tables Device and Room have Device/Room info, and the table EnergyLog has the details from the log.