homebridge-edomoticz Plugin

Moderator: leecollings

ksacca
Posts: 80
Joined: Thursday 31 May 2018 21:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: homebridge-edomoticz Plugin

Post by ksacca »

@robbie - You are not the only one. I have the exact same issue, but only if using the slider. When setting a level using Siri, it works correctly.
I control around 10 fibaro dimmers and 3 fibaro roller shutters (even tested with a dummy dimmer & shutter). All devices that use the slider increments by one.

The only thing I know is that the level set by homebridge is never the requested level. If I ask Siri to set my dimmer to 50%, it is set to 51.
Using the slider, and setting 50 sets it to 51% in domoticz. This probably sends an update, which sets the slider to 51, which in turn sets it to 52.
If you slide and immediately close the slider page, the increment stops. If you ever find a solution, please let me know as well :D .
ksacca
Posts: 80
Joined: Thursday 31 May 2018 21:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: homebridge-edomoticz Plugin

Post by ksacca »

It indeed seems to be looping as the svalue is incremented by 1 eacht time, which triggers a domoticz/out message with a different svalue updating the dimmer in homebridge (and so on).

domoticz/in

Code: Select all

domoticz/in {"command":"switchlight","idx":47,"level":10,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":47,"level":11,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":47,"level":12,"switchcmd":"Set Level"}
domoticz/out

Code: Select all

domoticz/out {
   "Battery" : 255,
   "Level" : 10,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Light/Switch",
   "id" : "00000501",
   "idx" : 47,
   "name" : "Keuken",
   "nvalue" : 2,
   "stype" : "Switch",
   "svalue1" : "10",
   "switchType" : "Dimmer",
   "unit" : 1
}

domoticz/out {
   "Battery" : 255,
   "Level" : 11,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Light/Switch",
   "id" : "00000501",
   "idx" : 47,
   "name" : "Keuken",
   "nvalue" : 2,
   "stype" : "Switch",
   "svalue1" : "11",
   "switchType" : "Dimmer",
   "unit" : 1
}

domoticz/out {
   "Battery" : 255,
   "Level" : 12,
   "RSSI" : 12,
   "description" : "",
   "dtype" : "Light/Switch",
   "id" : "00000501",
   "idx" : 47,
   "name" : "Keuken",
   "nvalue" : 2,
   "stype" : "Switch",
   "svalue1" : "12",
   "switchType" : "Dimmer",
   "unit" : 1
}
TroLoo
Posts: 9
Joined: Wednesday 24 January 2018 17:48
Target OS: -
Domoticz version:
Contact:

Re: homebridge-edomoticz Plugin

Post by TroLoo »

I am glad I am not the only one with this issue (I think that's the one).

When using device with slider while MQTT enabled (it can be light brightness, fan speed, roller shutter), it never goes to the point and stays there. My blinds are going up and down for 10-20 seconds moving to different positions. It is actually completely useless like this :(

I even made a video to better present what's going on:

https://youtu.be/FwIzWHbzv-U

Look like MQTT message sends increments to Domoticz device rather than set's it to the point, should be pretty ease to fix I think...
ksacca
Posts: 80
Joined: Thursday 31 May 2018 21:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: homebridge-edomoticz Plugin

Post by ksacca »

I'm no programmer so I'm probably completely wrong, but in domoticz_accessory.js, in the setdValue function (set dimmer value), is incremented:

Code: Select all

 var dim = Math.floor(level / this.factor) + 1;
2 values are used here. Level, which is probably the requested level and factor, which is a formula to derive a device with a dimlevel > 100 to a dimmer with maxlevel 100:

Code: Select all

this.factor = 100 / s.MaxDimLevel;
If we set level 50 for example, you get 50 (level) / 1 (factor) +1 which equals 51, so the requested level is always incremented by 1, no?

Code: Select all

    setdValue: function (level, callback, context) {
        this.cachedValues[Characteristic.Brightness.UUID] = level;
        if (context && context == "eDomoticz-MQTT") {
            callback();
            return;
        }

        if (!(this.factor)) {
            Domoticz.deviceStatus(this, function (json) {
                var sArray = Helper.sortByKey(json.result, "Name");
                sArray.map(function (s) {
                    this.factor = 100 / s.MaxDimLevel;
                }.bind(this));
            }.bind(this));
        }

        var dim = Math.floor(level / this.factor) + 1;
        Domoticz.updateDeviceStatus(this, "switchlight", {
            "switchcmd": "Set Level",
            "level": dim
        }, function (success) {
            callback();
        }.bind(this));
    },
    

Edit: I'm at home now, so I tested by removing the +1 from /usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js and now the sliders work as they should.
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: homebridge-edomoticz Plugin

Post by Robbie »

ksacca wrote: Thursday 08 August 2019 15:28 Edit: I'm at home now, so I tested by removing the +1 from /usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js and now the sliders work as they should.
The “+1” must be there for a reason. Maybe Marcie can weigh in here?

@ksacca - Can you test if you (with your edit) can still set the level to 100? I suspect it results in level 99
ksacca
Posts: 80
Joined: Thursday 31 May 2018 21:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: homebridge-edomoticz Plugin

Post by ksacca »

I agree the +1 must be there for a reason. It was added here: https://github.com/PatchworkBoy/homebri ... 4bff9be219.

I have no issues setting any level however:

Code: Select all

domoticz/in {"command":"switchlight","idx":89,"switchcmd":"On"}
domoticz/in {"command":"switchlight","idx":89,"level":100,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":89,"level":50,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":89,"level":0,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":89,"switchcmd":"Off"}
TroLoo
Posts: 9
Joined: Wednesday 24 January 2018 17:48
Target OS: -
Domoticz version:
Contact:

Re: homebridge-edomoticz Plugin

Post by TroLoo »

TroLoo wrote: Thursday 08 August 2019 10:16 I am glad I am not the only one with this issue (I think that's the one).

When using device with slider while MQTT enabled (it can be light brightness, fan speed, roller shutter), it never goes to the point and stays there. My blinds are going up and down for 10-20 seconds moving to different positions. It is actually completely useless like this :(

I even made a video to better present what's going on:

https://youtu.be/FwIzWHbzv-U

Look like MQTT message sends increments to Domoticz device rather than set's it to the point, should be pretty ease to fix I think...
It looks like when I use a slider, it enters some sort of a loop, take a look at what edomoticz device send to mqtt (clicked only once in Home app to change level to ~85%):

Code: Select all

domoticz/in {"command":"switchlight","idx":134,"level":96,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":92,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":88,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":86,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":87,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":88,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":89,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":90,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":91,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":92,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":93,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":94,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":95,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":96,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":97,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":98,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":99,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":100,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"switchcmd":"On"}
domoticz/in {"command":"switchlight","idx":134,"level":97,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":98,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":97,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":97,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":93,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":94,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":95,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":96,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":97,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":98,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":99,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":100,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"switchcmd":"On"}
domoticz/in {"command":"switchlight","idx":134,"level":93,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":94,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":95,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":96,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":96,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":97,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":98,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":99,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":100,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"switchcmd":"On"}
domoticz/in {"command":"switchlight","idx":134,"level":96,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":97,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":98,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":99,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"level":100,"switchcmd":"Set Level"}
domoticz/in {"command":"switchlight","idx":134,"switchcmd":"On"}
domoticz/in {"command":"switchlight","idx":134,"level":97,"switchcmd":"Set Level"}
User avatar
Marci
Posts: 531
Joined: Friday 22 January 2016 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: homebridge-edomoticz Plugin

Post by Marci »

If you wade back to page 50 or something, @TheRamon added the +1 to fix a previous issue where it would never truly set a dimmer to maximum for certain devices (I think - s’one I wasn’t involved with, as I don’t own anything dimmable)... it would always set 99% (or 96% in the case of Hue lamps). See somewhere around here in the thread: https://www.domoticz.com/forum/viewtopi ... 80#p104123

Loose summary - HomeKit rounds .0 thru 0.49 downwards, and .5 thru .99 upwards. Domoticz rounds all decimals downwards (or used to - need to investigate). Something along those lines. To understand more you’d need to go to the link quoted above and read about 15 pages worth of posts.

Short-term fix, edit lib/domoticz_accessory.js, and search out line 203...

Code: Select all

var dim = Math.floor(level / this.factor) + 1;
and change it to

Code: Select all

var dim = Math.floor(level / this.factor);
...as mentioned by @ksacca above, and restart homebridge, and see whether you can set dimmers to 100% or not (and whether that bothers you or not). I’ll have to have a thorough read of that section of the thread and try and work out whether the issue that the + 1 was there to fix still remains.

EDIT: Just borrowed a Hue Ambience from a neighbour and seems to be able to set 100% fine with the +1 removed here (altho had to set it twice as first time it set 96, as @TheRamon mentions)... and no continuous climbing. Whether it’s the same for other dimmables - no idea.

Whether it fixes blinds, can’t say (again, don’t have any) - problem is the implementation of sliders within iOS apps - they send out a rapid stream of increments if you touch+drag the slider, then network latency gets involved and things overlap & get confused (s’the same reason the Hue Camera app lags behind your TV progressively more and more when it’s dynamically controlling bulbs). You’re better just tapping where you want the slider to end up in your HomeKit app than actually dragging it to where you want it, or as also pointed out elsewhere, set it with Siri (or Alexa if you’ve installed homebridge-alexa, which coincidentally works fine alongside homebridge-edomoticz) as then it just fires a single target percent rather than every step on the slider between start position and end position (if making the quick fix above doesn’t resolve). Your Homebridge install has no concept of touch start and touch end to know when your movement has finished, so can’t really change the behaviour.

If it comes down to it, a config flag could be added in config.json to choose between the (default) +1 behaviour and without the +1 to avoid major breakages.
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!
TroLoo
Posts: 9
Joined: Wednesday 24 January 2018 17:48
Target OS: -
Domoticz version:
Contact:

Re: homebridge-edomoticz Plugin

Post by TroLoo »

Unfortunately, it's not the case in my opinion...

It's not about general compatibility of homebridge with Home app and sliders. Shit happens only when MQTT is enabled. When I turn it off in config.json, all blinds, lights and anything else with slider work fine! Only when I enable MQTT (change value in config.json to 1), this occurs.

After I removed '+1' in /usr/local/lib/node_modules/homebridge-edomoticz/lib/domoticz_accessory.js, line 203, whatever you do with slider, the blind (or light) reacts by going one bit up and immediately one bit down, then stops.

Any other ideas?
User avatar
Marci
Posts: 531
Joined: Friday 22 January 2016 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: homebridge-edomoticz Plugin

Post by Marci »

Yes, because with MQTT enabled the data is streamed in realtime back and forth between edomoticz and Domoticz. With the +1 in the code, what you set never matches what ends up in Domoticz. Domoticz ends up 1 higher, and that then gets picked up over MQTT by edomoticz and it gets nudged up one and around we go. Removing the +1 IS the fix to stop the loop. Did you purge your accessoryCache afterwards in .homebridge to ensure that the changes were picked up?

You only see it when MQTT is enabled, because otherwise, updates don’t go from Domoticz > edomoticz unless homebridge specifically requests them, and then you end up with switches etc out of sync if things are operated from outside of HomeKit land.

There is no difference in edomoticz’ code handling dimmers for MQTT enabled and disabled other than one way data is pushed immediately back and forth in both directions. With MQTT disabled, data is only ever pulled from Domoticz on demand by homebridge. Changes made in Domoticz won’t be reflected in HomeKit apps until a refresh is manually triggered in that app.

If everything "works fine" with MQTT disabled, then disable it.
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: homebridge-edomoticz Plugin

Post by Robbie »

Marci, can you add a flag for it in the config?
I am running homebridge in a docker container, and it reloads all modules on every startup. Its a bit of a hassle to statically make the edit in this setup
User avatar
Marci
Posts: 531
Joined: Friday 22 January 2016 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: homebridge-edomoticz Plugin

Post by Marci »

Is docker installing it from npmjs or github? (Problems updating npm at the moment)
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: homebridge-edomoticz Plugin

Post by Robbie »

Ah yes, that would be npm.

Just whenever you get it sorted.

As an extra note; To me it seems more logical to exclude the +1 by default. For whom is experiencing problems with the default functionality could then add the +1 from within config. Perhaps something to consider.
User avatar
Marci
Posts: 531
Joined: Friday 22 January 2016 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: homebridge-edomoticz Plugin

Post by Marci »

Righty - should be updated on both github and npmjs now... give it a whirl.

For users who need the +1 fix for obscure dimmer scaling / rounding issues, set

Code: Select all

"dimFix": 1
in config.json.

Omitting the dimFix variable entirely, or setting it to 0, will give expected "standard" behaviour.
The npmjs update also formally enables RGBWWZ support (which was added in the github repo earlier this month).

Also, as current versions of npm no longer utilise package-lock, package-lock.json has now been removed, which clears a few security vulnerability warnings from older versions of some dependencies.
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: homebridge-edomoticz Plugin

Post by Robbie »

Really great! Thanks a bunch
Robbie
Posts: 29
Joined: Friday 04 September 2015 1:15
Target OS: NAS (Synology & others)
Domoticz version: 2.2980
Contact:

Re: homebridge-edomoticz Plugin

Post by Robbie »

I was just thinking about the +1 fix.. If it was specifically needed for Hue lights, then wouldnt it make sense if these lights were added to homekit directly from within the Hue-app? Hue is fully homekit supported, so why would one need homebridge for this?
kratax
Posts: 21
Joined: Tuesday 30 April 2019 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: homebridge-edomoticz Plugin

Post by kratax »

Hello,
Is it somehow possible to set up homebridge with domoticz to be able to set thermostats with 0.5° steps instead of 1°C steps?
Thanks a lot.
Regards
kratax
Jordindc
Posts: 13
Joined: Monday 31 December 2018 7:48
Target OS: Linux
Domoticz version: 2020.2
Contact:

Re: homebridge-edomoticz Plugin

Post by Jordindc »

Robbie wrote: Thursday 05 September 2019 13:24 I was just thinking about the +1 fix.. If it was specifically needed for Hue lights, then wouldnt it make sense if these lights were added to homekit directly from within the Hue-app? Hue is fully homekit supported, so why would one need homebridge for this?
Adding Hue lights through domoticz, allows to include these devices in your domoticz scripts. If you add Hue devices directly to Homekit, they will not shown in domoticz environment.

Regards
TroisSix
Posts: 91
Joined: Monday 11 January 2016 9:29
Target OS: -
Domoticz version: 2022.2
Location: France
Contact:

Re: homebridge-edomoticz Plugin

Post by TroisSix »

Hi
Am I the only one to use IOS13 here?
It seems Apple inverted celsius and fahrenheit... Siri is giving me a "temperature of -6 degrees celsius" unless in my Home App I have a real 23.5 degrees celsius... And when I switch my iphone to the unit fahrenheit, I get a 24 degrees fahrenheit from Siri... wtf lol
Why did I upgraded my IOS to the last version :roll:
VM Debian - Domoticz stable v2023.1, RFXtrx433, Aeotec Z-Stick Gen5, APC ES700
- rts: dio, oregon, somfy
- zwave: fibaro fgs212, aeotec smart switch, vision ZG8101
- IO Homecontrol: Velux Connexoon
- logitech harmony hub, philips hue, gps Pilot
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: homebridge-edomoticz Plugin

Post by krizzz »

TroisSix wrote:Hi
Am I the only one to use IOS13 here?
It seems Apple inverted celsius and fahrenheit... Siri is giving me a "temperature of -6 degrees celsius" unless in my Home App I have a real 23.5 degrees celsius... And when I switch my iphone to the unit fahrenheit, I get a 24 degrees fahrenheit from Siri... wtf lol
Why did I upgraded my IOS to the last version :roll:
Haha tried it, same result for me! In the Home app OK but through Siri its -5 degrees Celsius.


Verzonden vanaf mijn iPhone met Tapatalk
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest