gaetancollaud / digitalstrom-mqtt

Bridge between digitalSTROM and MQTT
GNU Affero General Public License v3.0
24 stars 4 forks source link

no state by the switch itself in HomeAssistant #20

Closed Knobiwahn closed 2 years ago

Knobiwahn commented 2 years ago

Hello

i need some help, i decided after years to use homeassistant now. Ive got a Digitalstrom solution at home …what a disaster. Ive Integrated one device over mqtt. the Problem is that i can switch the light on but the Virtual Switch plops back to off but the light is still on. So maybe i dont get the state of the device or i configured something wrong. when i switch the Virtual Switch fastly enough i can turn off the light. But the state of the device will never show the right status dosent matter if i use the physical switch or in a different app. In Mqtt it shows the right status. here is the config of the switch.

mqtt: broker: http://homeassistant.local

switch: platform: mqtt command_topic: "digitalstrom/devices/Treppenbeleuchtung/brightness/command" state_topic: "digitalstrom/devices/Treppenbeleuchtung/brightness/state" payload_on: "100" state_on: on payload_off: "0" state_off: off optimistic: false name: "lichtschalter"

gaetancollaud commented 2 years ago

Hello,

I'm sorry but I don't use HomeAssistant so I cannot really help you. I use Openhab. I think you would have better luck on the home assistant forum.

Just be aware that you cannot use "on" or "off" with digitalstrom-mqtt, you have to use numbers between 0 and 100 for lights. If your light supports dimming, you can use a slider in HomeAssistant I guess.

My suggestion is to use https://mqtt-explorer.com/ to debug what's happening on MQTT. You have to write to the "command" topic and read on the "state" topic. But looking at your config, you got that right. Not sure what state_on and state_off are doing though...

If you manage to make it work, can you provide me with your working config, please? So I can put some documentation here. I wanted to do that for Openhab already but got lazy.

Druesel commented 2 years ago

Hi @Knobiwahn

With my Digitalstrom installation I have reached a similar point as you. In principle, I am still quite happy with the system, but the integration options have not been pushed as far as they were announced years ago. Long story short, I'm now also making a try with Home Assistant as a supervisor. On the one hand for the integration of additional ecosystems, on the other hand as visualization. At DS they never really took that seriously, unfortunately.

After all, I've come to the point where I can control simple lamps cleanly. had also only tried it like you did with "Switch". Ultimately, however, it works quite well with the "light" profile.

Try this in your configuration.yaml 😉

light:
  - platform: mqtt
    unique_id: Treppenhausbeleuchtung
    name: "Treppenhausbeleuchtung"
    state_topic: "digitalstrom/devices/Treppenbeleuchtung/brightness/state"
    command_topic: "digitalstrom/devices/Treppenbeleuchtung/brightness/command"
    on_command_type: brightness
    brightness_scale: 100
    brightness_state_topic: 'digitalstrom/devices/Treppenbeleuchtung/brightness/state'
    brightness_command_topic: 'digitalstrom/devices/Treppenbeleuchtung/brightness/command'
    payload_off: '0'
    optimistic: true

Good luck and get in touch if you have already found new insights or opportunities to integrate DS into HA via this MQTT integration or otherwise.

089digit commented 2 years ago

Hi,

the configuration for the lights works perfectly but my cover config doesn´t show me the position state .

`# Wohnzimmer Gartentor
  - platform: mqtt 
    name: "Wohnzimmer Gartentor" 
    state_topic: "digitalstrom/devices/WZ_-_Gartentor/shadePositionOutside/state"
    command_topic: "digitalstrom/devices/WZ_-_Gartentor/shadePositionOutside/command"
    qos: 0
    retain: true
    payload_open: "100"
    payload_close: "0"
    payload_stop: "STOP"
    position_open: 100
    position_closed: 0
    payload_available: "online"
    payload_not_available: "offline"
    optimistic: false`
tchatziliadis commented 2 years ago

If you still need help with covers, this is my config and working fine:

- platform: mqtt
  device_class: shutter
  name: "Ρολό Κουζίνας"
  command_topic: "digitalstrom/devices/Roller_Shutter_Kitchen/shadePositionOutside/command"
  position_topic: "digitalstrom/devices/Roller_Shutter_Kitchen/shadePositionOutside/state"
  set_position_topic: "digitalstrom/devices/Roller_Shutter_Kitchen/shadePositionOutside/command"
  payload_open: "100"
  payload_close: "0"
  payload_stop: "STOP"
  state_open: "open"
  state_opening: "opening"
  state_closed: "closed"
  state_closing: "closing"
  qos: 0
  retain: true
  optimistic: false
gaetancollaud commented 2 years ago

Thanks @tchatziliadis for your comment. I put it as reference in the documentation

@Knobiwahn I will close this. Feel free to comment or reopen if your issue is not solved.

FastestNinjaAlive commented 2 years ago

Hi @Knobiwahn

With my Digitalstrom installation I have reached a similar point as you. In principle, I am still quite happy with the system, but the integration options have not been pushed as far as they were announced years ago. Long story short, I'm now also making a try with Home Assistant as a supervisor. On the one hand for the integration of additional ecosystems, on the other hand as visualization. At DS they never really took that seriously, unfortunately.

After all, I've come to the point where I can control simple lamps cleanly. had also only tried it like you did with "Switch". Ultimately, however, it works quite well with the "light" profile.

Try this in your configuration.yaml 😉

light:
  - platform: mqtt
    unique_id: Treppenhausbeleuchtung
    name: "Treppenhausbeleuchtung"
    state_topic: "digitalstrom/devices/Treppenbeleuchtung/brightness/state"
    command_topic: "digitalstrom/devices/Treppenbeleuchtung/brightness/command"
    on_command_type: brightness
    brightness_scale: 100
    brightness_state_topic: 'digitalstrom/devices/Treppenbeleuchtung/brightness/state'
    brightness_command_topic: 'digitalstrom/devices/Treppenbeleuchtung/brightness/command'
    payload_off: '0'
    optimistic: true

Good luck and get in touch if you have already found new insights or opportunities to integrate DS into HA via this MQTT integration or otherwise.

Hi Druesel,

Thanks for the above, it works really well. I am quite new to all this smart home automation, so still learning a lot. With the above script entered in my yaml file I can control the DS lights indeed in HA. However, if I flip a physical switch of one of the DS lights, the state is not updated in HA. My MQTT explorer does show a state change being send, but I guess it is not picked up. Is this issue familiar to you?

Do you know how to fix it?

Thanks a lot!

Steev

gaetancollaud commented 2 years ago

Hi @FastestNinjaAlive

Can you try to update to the latest version? Because in version 1.4.3 I introduced the bug that you just described (no update when switching something). I fixed it in 1.4.5 (current version).

Cheers

FastestNinjaAlive commented 2 years ago

Hi @gaetancollaud ,

Thanks for the response. I checked and I have the 1.4.5 version running, so I guess it is not that.

I will have a better look over the weekend and otherwise re-install your software. I see there is 1.4.6 out as well.

Ciao&thanks!

FastestNinjaAlive commented 2 years ago

Hi @gaetancollaud,

I updated all to v 1.4.6 and the issue is still popping up. I am clueless what could be wrong. Do you have an idea perhaps? Regards and thanks a lot!

Steev

gaetancollaud commented 2 years ago

Could you please open a new issue.

Please run the application with the log level to TRACE (see readme). And provides the long. Especially when you change the state of the light.

If it doesn't work in MQTT it won't work in home assistant.

FastestNinjaAlive commented 2 years ago

@gaetancollaud,

You might have noticed I closed the issue that I raised earlier. Just wanted to share the configuration I currently have in my home assistant configuration file that works perfectly. In the end the issues that I had was that the payloads need to be entered with decimals... so 0.00 and 100.00 instead of 0 and 100.

Maybe the below is useful for others as example.

light: 
  - platform: mqtt
    unique_id: Licht_Bijkamer_dgts
    name: "Bijkamer"
    state_topic: "digitalstrom/devices/Licht_Bijkamer_dgts/brightness/state"
    command_topic: "digitalstrom/devices/Licht_Bijkamer_dgts/brightness/command"
    state_value_template: "{{ '0.00' if value == '0.00' else '100.00' }}"
    on_command_type: brightness
    brightness_scale: 100
    brightness_state_topic: 'digitalstrom/devices/Licht_Bijkamer_dgts/brightness/state'
    brightness_command_topic: 'digitalstrom/devices/Licht_Bijkamer_dgts/brightness/command'
    payload_on: '100.00'
    payload_off: '0.00'