cyberjunky / home-assistant-custom-components

My custom components for Home Assistant
MIT License
71 stars 19 forks source link

Different device ID #3

Closed RudolfRendier closed 4 years ago

RudolfRendier commented 6 years ago

This is the output of my toon, it seems to use a newer(?) device-ID

{ "dev_settings_device":{"uuid":"xxxxxxxxxxxxxx", "name":"settings_device", "internalAddress":"settings_device", "type":"settings_device", "supportsCrc":"0", "location":"(null)"}, "dev_10":{"uuid":"xxxxxxxxxxxxxx", "name":"HAE_METER_v3", "internalAddress":"10", "type":"HAE_METER_v3", "supportsCrc":"1", "ccList":"5e 86 72 32 56 5a 59 85 73 7a 60 8e 22 70 8b 3c 3d 3e", "supportedCC":"5e 86 72 32 56 5a 59 85 73 7a 60 8e 22 70 8b 3c 3d 3e", "IsConnected":"1", "DeviceName":"", "HealthValue":"10", "location":"(null)"}, "dev_10.1":{"uuid":"xxxxxxxxxxxxxx", "name":"HAE_METER_v3_1", "internalAddress":"10.1", "type":"gas", "supportsCrc":"0", "ccList":"5e 59 85 8e 3c 3d 3e", "supportedCC":"5e 59 85 8e 3c 3d 3e", "CurrentGasFlow":"623.00", "CurrentGasQuantity":"9840.00", "location":"(null)"}, "dev_10.2":{"uuid":"xxxxxxxxxxxxxx", "name":"HAE_METER_v3_2", "internalAddress":"10.2", "type":"elec", "supportsCrc":"0", "ccList":"5e 59 85 8e 3c 3d 3e", "supportedCC":"5e 59 85 8e 3c 3d 3e", "CurrentElectricityFlow":"3163.00", "CurrentElectricityQuantity":"21848.00", "location":"(null)"}, "dev_10.3":{"uuid":"xxxxxxxxxxxxxx", "name":"HAE_METER_v3_3", "internalAddress":"10.3", "type":"elec_solar", "supportsCrc":"0", "ccList":"5e 59 85 8e 3c 3d 3e", "supportedCC":"5e 59 85 8e 3c 3d 3e", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"}, "dev_10.4":{"uuid":"xxxxxxxxxxxxxx", "name":"HAE_METER_v3_4", "internalAddress":"10.4", "type":"elec_delivered_nt", "supportsCrc":"0", "ccList":"5e 59 85 8e 3c 3d 3e", "supportedCC":"5e 59 85 8e 3c 3d 3e", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"}, "dev_10.5":{"uuid":"xxxxxxxxxxxxxx", "name":"HAE_METER_v3_5", "internalAddress":"10.5", "type":"elec_received_nt", "supportsCrc":"0", "ccList":"5e 59 85 8e 3c 3d 3e", "supportedCC":"5e 59 85 8e 3c 3d 3e", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"}, "dev_10.6":{"uuid":"xxxxxxxxxxxxxx", "name":"HAE_METER_v3_6", "internalAddress":"10.6", "type":"elec_delivered_lt", "supportsCrc":"0", "ccList":"5e 59 85 8e 3c 3d 3e", "supportedCC":"5e 59 85 8e 3c 3d 3e", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"}, "dev_10.7":{"uuid":"xxxxxxxxxxxxxx", "name":"HAE_METER_v3_7", "internalAddress":"10.7", "type":"elec_received_lt", "supportsCrc":"0", "ccList":"5e 59 85 8e 3c 3d 3e", "supportedCC":"5e 59 85 8e 3c 3d 3e", "CurrentElectricityFlow":"NaN", "CurrentElectricityQuantity":"NaN", "location":"(null)"}, "dev_10.8":{"uuid":"xxxxxxxxxxxxxx", "name":"HAE_METER_v3_8", "internalAddress":"10.8", "type":"heat", "supportsCrc":"0", "ccList":"5e 59 85 8e 3c 3d 3e", "supportedCC":"5e 59 85 8e 3c 3d 3e", "CurrentHeatQuantity":"NaN", "location":"(null)"} }

I changed every dev_3. to dev_10. and that seems to work. Thanks for sharing your code!

~~Only Toon Gas Used Last Hour is 0.0 I still need to figure out why.~~ It seems 'last hour' confused me, it's current gas usage only. The value is valid, but returns to 0 when the flow stops.

cyberjunky commented 6 years ago

I guess I called it wrongly then, I thought P1 only reports gas usages once per hour. Maybe I have to make device ID configurable, we have three different ones now.

Emacee commented 6 years ago

For me this modification to the values works. Making the device ID configurable would be a really nice feature for less experienced users I think.

"""Modify the dev_3.X below to your needs. This differs per type of meteradapter. Newer types are dev_3.X older are dev_2.X"""
        """Go to http://toon.ip:port/hdrv_zwave?action=getDevices.json and search for dev_"""
        if self.type == 'gasused':
            if 'dev_4.1' in energy:
                self._state = float(energy["dev_4.1"]["CurrentGasFlow"])/100
            elif 'dev_3.1' in energy:
                self._state = float(energy["dev_3.1"]["CurrentGasFlow"])/100

        elif self.type == 'gasusedcnt':
            if 'dev_4.1' in energy:
                self._state = float(energy["dev_4.1"]["CurrentGasQuantity"])/1000
            elif 'dev_3.1' in energy:
                self._state = float(energy["dev_3.1"]["CurrentGasQuantity"])/1000

        elif self.type == 'elecusageflowpulse':
            self._state = energy["dev_4.2"]["CurrentElectricityFlow"]
        elif self.type == 'elecusagecntpulse':
            self._state = float(energy["dev_3.2"]["CurrentElectricityQuantity"])/1000

        elif self.type == 'elecusageflowlow':
            if 'dev_4.6' in energy:
                self._state = energy["dev_4.6"]["CurrentElectricityFlow"]
            elif 'dev_3.6' in energy:
                self._state = energy["dev_3.6"]["CurrentElectricityFlow"]

        elif self.type == 'elecusagecntlow':
            if 'dev_4.6' in energy:
                self._state = float(energy["dev_4.6"]["CurrentElectricityQuantity"])/1000
            elif 'dev_3.6' in energy:
                self._state = float(energy["dev_3.6"]["CurrentElectricityQuantity"])/1000

        elif self.type == 'elecusageflowhigh':
            if 'dev_4.4' in energy:
                self._state = energy["dev_4.4"]["CurrentElectricityFlow"]
            elif 'dev_3.4' in energy:
                self._state = energy["dev_3.4"]["CurrentElectricityFlow"]

        elif self.type == 'elecusagecnthigh':
            if 'dev_4.4' in energy:
                self._state = float(energy["dev_4.4"]["CurrentElectricityQuantity"])/1000
            elif 'dev_3.4' in energy:
                self._state = float(energy["dev_3.4"]["CurrentElectricityQuantity"])/1000

        elif self.type == 'elecprodflowlow':
            if 'dev_4.7' in energy:
                self._state = energy["dev_4.7"]["CurrentElectricityFlow"]
            elif 'dev_3.7' in energy:
                self._state = energy["dev_3.7"]["CurrentElectricityFlow"]

        elif self.type == 'elecprodcntlow':
            if 'dev_4.7' in energy:
                self._state = float(energy["dev_4.7"]["CurrentElectricityQuantity"])/1000
            elif 'dev_3.7' in energy:
                self._state = float(energy["dev_3.7"]["CurrentElectricityQuantity"])/1000

        elif self.type == 'elecprodflowhigh':
            if 'dev_4.5' in energy:
                self._state = energy["dev_4.5"]["CurrentElectricityFlow"]
            elif 'dev_3.5' in energy:
                self._state = energy["dev_3.5"]["CurrentElectricityFlow"]

        elif self.type == 'elecprodcnthigh':
            if 'dev_4.5' in energy:
                self._state = float(energy["dev_4.5"]["CurrentElectricityQuantity"])/1000
            elif 'dev_3.5' in energy:
                self._state = float(energy["dev_3.5"]["CurrentElectricityQuantity"])/1000

        elif self.type == 'elecsolar':
            if 'dev_4.3' in energy:
                self._state = energy["dev_4.3"]["CurrentElectricityFlow"]

        elif self.type == 'elecsolarcnt':
            if 'dev_4.3' in energy:
                self._state = float(energy["dev_4.3"]["CurrentElectricityQuantity"])/1000
cyberjunky commented 6 years ago

I have to compare the different json files I got, because I noticed that not only dev_X is different sometime s (this is easy to add as config option) but also the number behind is is swapped, that's weird...

RudolfRendier commented 6 years ago

I guess I called it wrongly then, I thought P1 only reports gas usages once per hour.

I think you are right about that, but I don't have a smart meter. My values are from a dumb meter and apparently the the values have a slightly different meaning. For me it updates more often and shows actual usage; as with electricity.