bdwilson / hubitat

Hubitat Contributions
18 stars 19 forks source link

hubitat code changes #14

Open andrewvanlagen opened 2 years ago

andrewvanlagen commented 2 years ago

i am trying to modify your hubitat genmon code

my cmd / status is

{"Status": [{"Engine": [{"Switch State": "Auto"}, {"Engine State": "Off - Ready"}, {"Battery Voltage": "13.50 V"}, {"RPM": "0 "}, {"Frequency": "0.00 Hz"}, {"Output Voltage": "0 V"}, {"Output Current": "0.00 A"}, {"Output Power (Single Phase)": "0.00 kW"}, {"Active Rotor Poles (Calculated)": "0 "}]}, {"Line": [{"Utility Voltage": "230 V"}, {"Utility Max Voltage": "246 V"}, {"Utility Min Voltage": "221 V"}, {"Utility Threshold Voltage": "156 V"}]}, {"External Temperature Sensors": [{"Main DS18B20": "24.06 C"}****, {"External DS18B20": "19.50 C"}]}, {"Last Log Entries": {"Logs": {"Alarm Log": "11/26/21 19:11:02 ESTOP Pressed : Alarm Code: 2800", "Service Log": "", "Run Log": "07/09/22 13:05:17 Stopped - Auto "}}}, {"Time": [{"Monitor Time": "Monday July 18, 2022 20:16:03"}, {"Generator Time": "Monday July 18, 2022 20:16"}]}]}

This is the code i try to add but it does load to hubitat is there anything im missing

  temp = resp1.data.Status[1].Line[0].'Utility Voltage'
        sendEvent(name: "Utility Voltage", value: temp, isStateChange: true)
        //LOGINFO("${temp}")
        state.UtilityVoltage = temp.replace(" V", "")
        sendEvent(name: "Utility Voltage Number", value: state.UtilityVoltage, isStateChange: true)

    temp = resp1.data.Status[2].External Temperature Sensors[0].'Main DS18B20'
        sendEvent(name: "Main DS18B20", value: temp, isStateChange: true)
        //LOGINFO("${temp}")
        state.MainDS18B20 = temp.replace(" C", "")
        sendEvent(name: "Main DS18B20 Number", value: state.MainDS18B20, isStateChange: true)

    state.LastService = resp1.data.Status[3]['Last Log Entries']['Logs']['Service Log']
        state.LastAlarm = resp1.data.Status[3]['Last Log Entries']['Logs']['Alarm Log']
        state.LastRun = resp1.data.Status[3]['Last Log Entries']['Logs']['Run Log']
        state.MonitorTime = resp1.data.Status[4].Time[0].'Monitor Time'
        state.GeneratorTime = resp1.data.Status[4].Time[1].'Generator Time'

thanks

andrewvanlagen commented 2 years ago

in my log i shows error. i wonder if the error are coming from External Temperature Sensors": [{"Main DS18B20": "24.06 C is there away that i can add it to the api/ driver code

andrewvanlagen commented 2 years ago

Do you have any way to make this work