Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A request to add a Water Counter type #40

Closed
dmikhalsky opened this issue Aug 31, 2016 · 21 comments
Closed

A request to add a Water Counter type #40

dmikhalsky opened this issue Aug 31, 2016 · 21 comments
Assignees

Comments

@dmikhalsky
Copy link

Here is the JSON outcome for the device:

{
"ActTime" : 1472668145,
"ServerTime" : "2016-08-31 21:29:05",
"Sunrise" : "05:34",
"Sunset" : "19:24",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"Counter" : "211.200 m3",
"CounterToday" : "100 Liter",
"CustomImage" : 0,
"Data" : "211.200 m3",
"Description" : "",
"Favorite" : 1,
"HardwareID" : 2,
"HardwareName" : "My GW",
"HardwareType" : "MySensors Gateway USB",
"HardwareTypeVal" : 41,
"HaveTimeout" : false,
"ID" : "0501",
"LastUpdate" : "2016-08-31 20:43:05",
"Name" : "Water Cold",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" : [ 0 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "RFXMeter counter",
"SwitchTypeVal" : 2,
"Timers" : "false",
"Type" : "RFXMeter",
"TypeImg" : "counter",
"Unit" : 0,
"Used" : 1,
"ValueQuantity" : "",
"ValueUnits" : "",
"XOffset" : "0",
"YOffset" : "0",
"idx" : "1"
}
],
"status" : "OK",
"title" : "Devices"
}

@dmikhalsky
Copy link
Author

Just to clarify: this is a standard mysensors pulse watermeter, not something exotic, so adding it might be useful

@PatchworkBoy
Copy link
Owner

Have added that particular type / subtype combination to the existing Watermeter service - Head to homebridge-edomoticz/lib...

sudo mv domoticz_accessory.js domoticz_accessory.bak 
sudo wget https://raw.githubusercontent.com/PatchworkBoy/homebridge-edomoticz/4f41b0719ccd30465fbf174808cfd99e69bae8a2/lib/domoticz_accessory.js

Test & let me know...!

@dmikhalsky
Copy link
Author

[eDomoticz] Initializing platform accessory 'Water Cold'...
/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:1218
var wMeterDeviceService = new (this.name);
^

TypeError: this.name is not a function
at Object.eDomoticzAccessory.getServices (/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:1218:33)
at Server._createAccessory (/usr/local/lib/node_modules/homebridge/lib/server.js:357:36)
at Server. (/usr/local/lib/node_modules/homebridge/lib/server.js:343:32)
at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:15:19
at callbackLater (/usr/local/lib/node_modules/homebridge-edomoticz/index.js:172:37)
at Object. (/usr/local/lib/node_modules/homebridge-edomoticz/index.js:201:17)
at Request.self.callback (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/request/request.js:198:22)
at emitTwo (events.js:87:13)
at Request.emit (events.js:172:7)
at Request. (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/request/request.js:1082:10)

@dmikhalsky
Copy link
Author

I assume the line
"var wMeterDeviceService = new (this.name);" should look like
"var wMeterDeviceService = new eDomoticzServices.MeterDeviceService(this.name);"

I corrected this, and also changed "CurrentConsumption" charachteristic to "Total consumption"

The counter is now listed in Eve, but:

  • it has 0, instead of data (except for Water Flow, it works and reflects current consuption)
  • it has Kwh istead of m3 (is there a "m3" in Homekit btw?)

@dmikhalsky
Copy link
Author

Ok, here what happens: when the counter changes in Domoticz, the correct value appears in Eve, but very briefly, than changes back to zero.
So it's not persistent.

@PatchworkBoy
Copy link
Owner

OK - give it another try now - I added it to completely the wrong characteristic last time. It’s now been shifted into a different one...

sudo mv domoticz_accessory.js domoticz_accessory.bak 
sudo wget https://raw.githubusercontent.com/PatchworkBoy/homebridge-edomoticz/mqtt-integration/lib/domoticz_accessory.js

@dmikhalsky
Copy link
Author

Thanks.
Good news: flow counters (current consumption) work FLAWLESSLY now
Bad news:

  • total consumption counters are not visible in Eve app
  • something is accidentally broken with dimmable lamps (homebridge crashes when switching them on/off talking about "brightness not being defined". Reverting back to original domoticz_accessory.js fixed this

@dmikhalsky
Copy link
Author

This type WORKS correctly:

{
"ActTime" : 1474567596,
"ServerTime" : "2016-09-22 21:06:36",
"Sunrise" : "06:16",
"Sunset" : "18:27",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "0.00 l/min",
"Description" : "",
"Favorite" : 1,
"HardwareID" : 9,
"HardwareName" : "My Pi",
"HardwareType" : "MySensors Gateway USB",
"HardwareTypeVal" : 41,
"HaveTimeout" : false,
"ID" : "00000501",
"Image" : "Moisture",
"LastUpdate" : "2016-09-22 21:02:44",
"Name" : "Расход (Холодная)",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" : [ 0 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "Waterflow",
"Timers" : "false",
"Type" : "General",
"TypeImg" : "moisture",
"Unit" : 1,
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "62"
}
],
"status" : "OK",
"title" : "Devices"
}

This DOESN'T:
{
"ActTime" : 1474567677,
"ServerTime" : "2016-09-22 21:07:57",
"Sunrise" : "06:16",
"Sunset" : "18:27",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"Counter" : "224.000 m3",
"CounterToday" : "400 Liter",
"CustomImage" : 0,
"Data" : "224.000 m3",
"Description" : "",
"Favorite" : 1,
"HardwareID" : 9,
"HardwareName" : "My Pi",
"HardwareType" : "MySensors Gateway USB",
"HardwareTypeVal" : 41,
"HaveTimeout" : false,
"ID" : "0501",
"LastUpdate" : "2016-09-22 19:57:32",
"Name" : "Счетчик (Холодная)",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" : [ 0 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "RFXMeter counter",
"SwitchTypeVal" : 2,
"Timers" : "false",
"Type" : "RFXMeter",
"TypeImg" : "counter",
"Unit" : 0,
"Used" : 1,
"ValueQuantity" : "",
"ValueUnits" : "",
"XOffset" : "0",
"YOffset" : "0",
"idx" : "66"
}
],
"status" : "OK",
"title" : "Devices"
}

@PatchworkBoy
Copy link
Owner

PatchworkBoy commented Sep 22, 2016

total consumption counters are not visible in Eve app

I’ve only written in Currentconsumption support... haven’t written in total consumption support.

something is accidentally broken with dimmable lamps (homebridge crashes when switching them on/off talking about "brightness not being defined". Reverting back to original domoticz_accessory.js fixed this

Dammit - I’ll have to drag @xTheRamon in on that - sorry Ramon - think I broke something in my manual merging!

This type WORKS correctly:

It’s just defaulting to a meter sensor which only shows the output from the Data: field in the JSON as the “Waterflow” subtype isn’t implicitly supported.

Different Type/SubType combinations have to be handled differently... for instance the first only presents the Data: field, whereas the second presents Counter & CounterToday which means needing their own service definitions. Units have to be stripped from the readings else you can’t use use the data for any automation rules.

I’m going to need MQTT output for the RFXMeter also if you can get it...? For most of my meters that output similarly to the RFXMeter, via MQTT domoticz ONLY sends current consumption. Never sends total consumption.

@dmikhalsky
Copy link
Author

I’m going to need MQTT output for the RFXMeter also if you can get it...? For most of my meters that output similarly to the RFXMeter, via MQTT domoticz ONLY sends current consumption. Never sends total consumption.

yes, I recall analyzing MQTT output and noticing it. One of many Domoticz oddities.
I'll look at it again and post RFXMeter MQTT output here

@dmikhalsky
Copy link
Author

Here we go:

{
"Battery" : 255,
"RSSI" : 12,
"dtype" : "RFXMeter",
"id" : "1280",
"idx" : 67,
"name" : "--------------",
"nvalue" : 0,
"stype" : "RFXMeter counter",
"svalue1" : "150700",
"unit" : 0
}
so, the actual value (sans decimal point) is in svalue1. If needed, 1000 is the correct divider, so the value displayed in Domoticz is 150.7

@PatchworkBoy
Copy link
Owner

PatchworkBoy commented Sep 22, 2016

Cool - ta... but which value - current flow rate, or total flow rate? It’s only sending one. At the moment I’m assuming that’s current flow rate??

@PatchworkBoy
Copy link
Owner

PatchworkBoy commented Sep 22, 2016

OK - back up current installation, and pull the mqtt-integration branch again... I’ve now added implicit water flow handling for both sensor types above, hopefully with correct units also. The brightness side of things I’ll have to leave to Ramon as I don’t actually HAVE any dimmers to diagnose with, and he wrote all of the dimming support in the plugin.

@dmikhalsky
Copy link
Author

Sorry if I made it not clear. I have 2 data types coming from the water meter: flow and total consumption.
Flow shows momentarily flow and with the latest commit is shown correctly in Eve. I haven't posted the JSON for it since it works but I can if needed.
Total consumption meter shows (you guess it!) total consumption since the time the counter was installed. The figure in svalue1 is the one I need and the one visible on the physical hardware.

There is the third parameter (dayly consumption) that Domoticz calculate itself. The node attached to the hardware counter doesn't send it. I know it for sure since I designed it :-)
And It seems not be available in mqtt output.

@PatchworkBoy
Copy link
Owner

Yep - got all that... latest commit should cover it correctly, for both your RFXMeter > RFXMeter Counter Device (IDX 66 - reading the Counter and CounterToday fields via HTTP, updating the Counter field from svalue1 via MQTT in realtime), and your General > Waterflow device (IDX 62 - reading just the Data field, updating just the data field from svalue1 via MQTT in realtime).

What I was trying to establish is:
If you take the MQTT output for IDX66, and compare it to the JSON output for IDX66, which two fields match up. What does svalue1 from the MQTT correlate to in the JSON.

@dmikhalsky
Copy link
Author

usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Service.js:52
this.getCharacteristic(Characteristic.Name) ||
^

TypeError: this.getCharacteristic is not a function
at Service (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Service.js:52:12)
at new eDomoticzServices.WaterDeviceService (/usr/local/lib/node_modules/homebridge-edomoticz/lib/services.js:98:13)
at Object.eDomoticzAccessory.getServices (/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:1249:31)
at Server._createAccessory (/usr/local/lib/node_modules/homebridge/lib/server.js:357:36)
at Server. (/usr/local/lib/node_modules/homebridge/lib/server.js:343:32)
at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:15:19
at Object. (/usr/local/lib/node_modules/homebridge-edomoticz/index.js:203:41)
at Request.self.callback (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/request/request.js:198:22)
at emitTwo (events.js:87:13)
at Request.emit (events.js:172:7)

@PatchworkBoy
Copy link
Owner

rolls eyes I forgot to add the new services to the inheritance patches. Repull index.js and should be fixed - sorry!

@dmikhalsky
Copy link
Author

/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:1250
WaterMeterService.getCharacteristic(eDomoticzServices.Waterflow).on('get', this.getStringValue.bind(this));
^

TypeError: Cannot read property 'on' of undefined
at Object.eDomoticzAccessory.getServices (/usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js:1250:71)
at Server._createAccessory (/usr/local/lib/node_modules/homebridge/lib/server.js:357:36)
at Server. (/usr/local/lib/node_modules/homebridge/lib/server.js:343:32)
at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:15:19
at Object. (/usr/local/lib/node_modules/homebridge-edomoticz/index.js:206:41)
at Request.self.callback (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/request/request.js:198:22)
at emitTwo (events.js:87:13)
at Request.emit (events.js:172:7)
at Request. (/usr/local/lib/node_modules/homebridge-edomoticz/node_modules/request/request.js:1082:10)
at emitOne (events.js:82:20)

@dmikhalsky
Copy link
Author

If you take the MQTT output for IDX66, and compare it to the JSON output for IDX66, which two fields match up. What does svalue1 from the MQTT correlate to in the JSON.

MQTT svalue1 "224500" partially correlates to JSON "Data" : "224.500 m3" or "Counter" : "224.500 m3"
There is no 1:1 match. It looks like MQTT provides raw data, while JSON is more "formatted" or "as is in GUI"

@rswilem
Copy link
Collaborator

rswilem commented Nov 11, 2016

I've only just now read that you dragged me in on this one. Haha. Whoops. I won't fix anything with dimmers now though as it seems they're working perfectly now.

@PatchworkBoy
Copy link
Owner

Create a new issue if still exists in current version - originally raised under v1.x - we’re not on v2.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants