fdebrus / NeopoolHomeAssistant

5 stars 1 forks source link

Question about dashboard regarding the light switch #3

Closed JHurk closed 1 year ago

JHurk commented 1 year ago

Got the dashboard to work and after enabling the SetOption19 in Tasmota the entities became visible in HA.

One question; I connected the pool lights to my Sugar Valley and I can control them with the switch on the dashboard. But how do I get the switch to show the current state, just like a normal switch or light bulb in HA? I know I can add it a a separate sensor to the dashboard, I did this for the Acid pump. But would like it to show up like a normal light in HA.

Schermafbeelding 2023-10-20 om 12 35 18

I tried making it a different device (from switch to light), it still functions but the state is also not visible. For extra info; I did not add a gui switch in Tasmota for the light (maybe I need to do that so it will transfer this to HA via MQTT??)

fdebrus commented 1 year ago

I have the same since HA upgrade, I've not yet figured out how to fix it. As I switched off the pool, will be complex to troubleshoot before post winter. It might be a general question to be asked in HA forum as it's related to how MQTT switches behave since last HA release. Will further investigate on the forum and revert if any findings

JHurk commented 1 year ago

Understood, if I can do anything to test, please let me know. I still have my pool operational for a week, max. two. So I can do some testing if you like, with different settings or yaml.

fdebrus commented 1 year ago
- unique_id: "pool_lights"
  name: "MQTT Pool Lights"
  device_class: switch
  command_topic: "cmnd/SmartPool/NPLight"
  state_topic: "stat/SmartPool/NPLIGHT"
  value_template: >- 
    {% set values = { 'OFF':'0', 'ON':'1' } %}
    {{ values[value_json["NPLight"]] if value_json["NPLight"] in values.keys() else '99' }}
  payload_on: "1"
  payload_off: "0"

using tool like MQTT explorer, could you check you get a topic value in "stat/SmartPool/NPLIGHT" ?

JHurk commented 1 year ago

Sorry, deleted my previous answer because it got a little complex.

  1. When I publish the following command, I get no result in HA explorer

    Scherm­afbeelding 2023-10-20 om 14 02 29
  2. But after a few minutes I do get an answer, probably because the automation SmartPool_Sensors_Updated got triggered.

    Scherm­afbeelding 2023-10-20 om 14 05 25
fdebrus commented 1 year ago

same here, status of the MQTT switch remains "unknown" even after posting to stat/SmartPool/NPLIGHT

image

JHurk commented 1 year ago

Same her, both for the lights and the pump switch. So something with the yaml? Or maybe the Tasmota doesn't publish the expected state?

Scherm­afbeelding 2023-10-20 om 14 09 38
fdebrus commented 1 year ago

it worked all fine for me before the latest HA upgrade, might be something has changed in the release.

So I woul not touch yaml nor tasmota. It's a new HA behavior that we need to figure out

JHurk commented 1 year ago

That is good call, will look into the latest HA upgrade to see if anything changed regarding MQTT and/or switch behaviour and state. But for now will stay away from editing Tasmota or yaml :)

JHurk commented 1 year ago

The only thing in the release notes that comes close to MQTT or this issue is; https://github.com/home-assistant/core/pull/101670 As far as I can tell, but my knowledge is not that extensive regarding bug fixing and coding.

fdebrus commented 1 year ago

got this working

mqtt: switch:

if I send OFF or ON to state/mySwitch, the dashboard item is updated accordingly. troubleshooting...

JHurk commented 1 year ago

Don't know if this is helping, seeing you already found some things during testing. But looked at the previous release notes of September and found the following changes/fixes that might be related;

September 8 release https://github.com/home-assistant/core/pull/99943 September 12 release https://github.com/home-assistant/core/pull/100168 (Tasmota related change/fix) September 24 release https://github.com/home-assistant/core/pull/100707 (MQTT state related)

JHurk commented 1 year ago

Nope, this doesn't change anything. The buttons work (On makes the gui in Tasmota change the lights to On), but the state is not visible in the dashboard. And via the developers tool --> status is still unknow The strange thing is that the last updated time is somewhere around 13:04, while I just changed the status via de the switch button on the dashboard, around 14:35. Correct; the time has changed after a refresh, so disregard this last comment.

Scherm­afbeelding 2023-10-20 om 14 41 52
fdebrus commented 1 year ago

You need to send 0 or 1 to command_topic: "cmnd/SmartPool/NPLight"

image

next Tasmota module will answer with ON or OFF on state_topic: "stat/SmartPool/NPLIGHT"

Somehow, when I combine value_template and payload_on payload_off. the state of the swith is no longer updated.

JHurk commented 1 year ago

Does this help?

Scherm­afbeelding 2023-10-20 om 14 56 37
fdebrus commented 1 year ago

Damned, coffee helped :) go to your tasmota console and enter the following command

setoption4 1

JHurk commented 1 year ago

That's it!!! The switch turned into a on/off switch instantly and shows the status. Thanks for this!

fdebrus commented 1 year ago

you're welcome. it will also resolve the pump switch status

JHurk commented 1 year ago

Thanks again, and to confirm; the pump switch is also working now!