Blue Series 2-1 Switch: Using ZHA vs zigbee2mqtt

Created this thread to continue my discussion of the issues I was having trying to get my first smart switch working. I had it setup in ZHA and seemed to be able to control it but I was having trouble trying to get the physical button presses working so that it could control a smart bulb (SENGLED). I don’t really need the light to be a smart bulb now that the switch came in but I thought it would be a good learning experience to figure out how to use the switch to control automations.

In the other thread I mentioned to @stu1811 that I tried zigbee2mqtt. You asked if I disabled ZHA and I did not. I just read that elsewhere on the net that you can’t have them both trying to use the same device and I did not realize that is what I was doing. My zigbee radio is built-in to my home assistant yellow box. I wasn’t really sure which port the zigbee was on but I assumed it was one of the /dev/tty/ devices and I believe it had “acm” in the name so I first tried 0 and then googling saw someone say the yellow used acm1. I assume I got the right one cause I noticed ZHA got stuck saying “initializing” until I disabled the mqtt stuff and rebooted. Now I know I need to disable ZHA first.

Doing a bunch of searching today it seemed like equal support for both options. When I looked up using the Mosquitto broker there was a warning about it being a Public broker and that it should only be used for testing but it wasn’t clear what I would need to switch to for it to be Private.

I’m just not seeing any events happen inside HA when I press the switch. I plan to factory reset it tonight so I get back to a known starting point.

Starting with the mosquitto addon. Here is my config. Note the secrets are defined in secrets.yaml.

Sample sercrets.yaml

mqtt_user: 'mqtt_username'
mqtt_pass: 'mqtt_super_secret_password'

=============================
Mosquitto Integration

==============
image

===================
Zigbee2mqtt addons - I have some options in the addon config and others in zigbee2mqtt/configuration.yaml. Not sure how they ended up in both places. Also note I’m using /dev/serial/by-id vs /dev/ttyUSB0. The USB devices (or others) and not guarantee
to be the same every time. The serial by-id will always be the same.

============================

devices:
  - devices.yaml
groups:
  - groups.yaml
homeassistant: true
permit_join: false
mqtt:
  base_topic: zigbee2mqtt
  user: addons
  password: SUPERSECRET
  server: mqtt://core-mosquitto:1883
serial:
  port: >-
    /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_e282945f5393eb11bbb41b4f3d98b6d1-if00-port0
advanced:
  log_level: error
  pan_id: 1234
  channel: 15
  network_key:
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
  availability_blocklist: []
  availability_passlist: []
  homeassistant_legacy_entity_attributes: false
  legacy_api: false
  legacy_availability_payload: false
  log_syslog:
    app_name: Zigbee2MQTT
    eol: /n
    host: localhost
    localhost: localhost
    path: /dev/log
    pid: process.pid
    port: 123
    protocol: tcp4
    type: '5424'
  transmit_power: 20
device_options:
  legacy: false
blocklist: []
passlist: []
queue: {}
frontend:
  port: 8099
experimental: {}
availability: false
ota:
  ikea_ota_use_test_url: false
  zigbee_ota_override_index_location: ota/index.json
  disable_automatic_update_check: true

===========
End results - Under integrations → MQTT - > Device X

===================
image

1 Like

Thanks for the settings Stu. I came home and did a factory reset of the switch, removed the device from HA, and started over. Everything worked as expected syncing it with ZHA. Even got the button presses working to control automations. So I’ll probably stick with this for now and save these MQTT settings for reference if I need them later.

I think one thing that made me think the dimming wasn’t working is the default ramp rates are so long I wasnt waiting long enough to see it dim. I need to figure out some good settings. I tried lowering the ramp rates but I cant make it feel natural. It’s like someone was saying how it brightens on a curve. Looks like it’s doing nothing then ramps real quick. Lower the ramp rate and then it feels like its taking forever and not working before it starts to dim.

1 Like

I think 3 seconds is the default

I’m thinking of trying to set this up and get Z2M going. @stu1811 where would I be creating the secrets.yaml file? I’m not familiar with where everything gets stored yet. I assume it would be under a config folder for mosquitto?

I played with the switch settings last night got it setup a little better. I noticed it was hard to see an increase in brightness once it got above 70% so I set the max load to 178. And then I found the lowest dimming setting I’d want so that the dimming shouldn’t waste time going outside the usable range I want. It still feels like it takes too long for it to start to dim but once it starts changing it seemed to go maybe too fast. I assumed it was the button delay causing that initial pause but I tried lowering from 5 to 2 and it still seems like its longer than 200ms before I see the light start to change. The ZHA parameter names don’t necessarily match the manual for the switch and it doesn’t seem to expose all of them. Like I found the one that allows the up double tap to jump the light to the max dim value but they did not expose the down double tap. Hoping Z2M will provide more options.

Secrets goes in your HA configuration directory which varies by installation. I’m using HA Supevised so it’s /usr/share/hassio/homeassistant/secrets.yaml . If you’re logging into core it should be the same directory as your main configuration.yaml. You can also use a plain string to start and then migrate to secrets if you’re happy with the result.

Here’s a snippet from Z2M. It’s much more user friendly.

Took me 2 hours messing around to finally get past the 502: Bad Gateway error when trying to open the MQTT webpage. I finally searched for “zigbee2mqtt configuration for home assistant yellow” and found a page for the Yellow that said I needed this:

Serial:
adapter: ezsp
port: /dev/ttyAMA1
baudrate: 115200
rtscts: true

So I got things working. I like how Z2M exposes all the attributes. I can’t seem to set the double tap down attribute I get an error saying unsupported attribute. Seems like the double tap up gives the same error but it appears to work on the switch. Double tap down does nothing. Still feels like a lot of lag before the local dimming makes the light change. Dimming is not relying on the Zigbee communication since I have dumb bulbs in there now so not sure why it seems like a big delay to start then choppy while dimming. I have the button delay at 200ms to try to make it fast while still allowing buttons to work.

Not sure if it’s because I switched to Z2M but it prompted me to update the firmware in the switch. Just bought it so surprised they couldn’t send me an updated device. The version was ending in 00 and the new version ends in 15.

It completely changed how the switch feels/works. Not all the changes are good. The double tap down works now. But now if I hold the button down it’s dimming past my minimum level all the way till the light turns off. Older FW didn’t have that problem. What’s worse is that once it dims down and the light is off doing a single press of the Up button fails to turn the light back on. Then I’m stuck either doing a double tap up or holding down the button to dim it back up. I’ve got the double tap limits set exactly the same as the min/max limits. (60/178). I started with the minimum at 40 but after it was doing this weird turning off I thought the limit might be too low so that’s why I’m trying 60. I’m unhappy with how this is working as a dimmer.

By default Z2M turns on update notifications.FYI after an update you should press the reconfigure button to reparse any new or changed parameters. Also 2.15 is the latest version.

Can you post your ramp rates and dimming speeds? FYI ramp rates are when you single press on or off. Dimming rates are while holding up or down.

Not sure I totally follow. Holding the down button should eventually turn it off. You mentioned setting min and max values of 60/178 or 23% / 70%; that means it scales the dimming so that when the dimmer is at 100% is actually outputting 70% and 1% is actually outputting 23%.

You want to set DefaultLevelLocal to 254. The default is 255 which will set it to the previous level (ie 1%) if you dimmed down. I fell like 254 should be the default value since IMO that is the expected behavior.

Regarding version: Yes if you goto the About page it’s showing 2.15 but that is not the version you are shown when upgrading. The version shown was 16908815 as you can see in the state screenshot below.

Regarding dimming: No holding the button down should not eventually turn the light off it should stop at whatever you’ve programmed as the minimum level. That’s supposed to be the purpose of that setting.

DefaultLocalLevel: I actually want this at 255 because we don’t want full brightness when the light is turned on. It’s way too bright. It’s supposed to go back to where it was when it was turned off which should always be inside the min/ max limits I’ve set.

So as a test I ramped up to full brightness. Then I held the down button. It ramped down and then did appear to stop so I thought it was working although it seemed lower than I expected. Then when I let go of,the button it dimmed way down more. So I check the state and the brightness is at a 2 which is violating my min/max settings. This was not happening in the 2.00 firmware.

16908815 is 2.15. I’m not sure how you convert between the two. Check out https://files.inovelli.com/firmware/firmware.json

{
      "version": "16908815",
      "channel": "beta",
      "firmware": "https://github.com/InovelliUSA/Firmware/raw/main/Blue-Series/Zigbee/VZM31-SN-2-1-Switch/Production/2.15/VZM31-SN_2.15-Production.ota",
      "manufacturer_id": 4655,
      "image_type": 257
    }

Remember it’s internally scaling the level on the switch to the min/max you defined. So a level of 255 equals the max you defined. As a quick test, first turn the light off, then set the max to 50% and at the switch hold the up paddle until fully on. Do the same test but set the max to 100%. You should see a noticeable difference.

I haven’t tested the Max its the Min I’m saying is having issues. I can do more tests but the test I have done is I set Min to 60…that setting doesn’t use percentage its 0 - 255. So that should set my minimum brightness when holding the down paddle to near 23% but I end up with the light so dim you can barely tell its lit. It did not do this with the earlier firmware.

Question is when I set my Min to 60 and my Double Down Tap to 60 should those end up causing the same brightness or is the Double Down Tap setting using the “magical” internal scaling?

Min should behave the same as the max value. I’ll do some tests with one of my blues and let you know.

I have 3 more switches supposed to be here Thursday so I’ve been waiting so I could test with them as well. They might come with the older FW like this one so I can compare and also double check that its not just this switch.

Ok I think I’m all sorted. I factory reset and started over. I think I was confused because I didn’t realize the double tap down setting was being scaled so when I had it and min both set to 60 the double tap would cause it to brighten. The other factor was I had switched from a smart bulb to a dumb bulb and the min brightness for the dumb bulb actually needs to be 90 to get to the brightness I wanted. The double tap set to 60 was making it look like the level I wanted. I know you were trying to tell me it scaled but I thought that was just for external commands not internal values like the double tap. I wanted the double tap down to give me my min brightness. I tried 0 for double tap but that turns it off. Then I tried 1 and that also cut it off. Had to use a 2 to get it to do what I wanted.

Sorry for the confusion and thanks for steering me right.

1 Like

Glad to hear you got it sorted out