Restarting HASS breaks functionality
I have my phev2mqtt as a service running on my PI and starts on boot after network is up. It works fine. However, every time I restart HASS, I have to restart phev2mqtt twice in order for the values to appear again in HA.
Is there a way to fix this?
For the time being I'm using the command-line integration to manually restart the service every time I restart Hass.. :)
I changed the HA discovery messages to retained and added some extra avaibility tweaks to fix this. Also, on my MY18 the battery level is always between 6 and 94, so I discarded other values to get rid of the random 5 and 255. If thats ok, I'll do a PR. https://github.com/buxtronix/phev2mqtt/compare/master...akoivist:phev2mqtt:master
I changed the HA discovery messages to retained and added some extra avaibility tweaks to fix this. Also, on my MY18 the battery level is always between 6 and 94, so I discarded other values to get rid of the random 5 and 255. If thats ok, I'll do a PR. master...akoivist:phev2mqtt:master
I would love to have this fixed. So for me, you can do a PR.
Looking at how other devices interact over MQTT with Home Assistant, most (if not all) topics are retained. Otherwise a restart of Home Assistant will cause all states to default to unavailable until phev2mqtt reports a change in one of the values.
For me, the issue remains. If HA is restarted, the entities of the CAR ar all unkown until I restart phev2mqtt.
For me, the issue remains.
Nothing has changed in this regard. I think the correct way to deal with unknown entities is to make all topics that phev2mqtt sends messages to need to be set to retained. Maybe this could even be a command line option to toggle the behavior for users that only want ad-hoc messages.
I have made various stability/mqtt/log fixes in my repo https://github.com/altserg/phev2mqtt The repo is not yet synced with main but it already has most of recent fixes ported manually. Can you try it and let me know if it works better for you ? If confirmed to work stable, I will re-create the branch from scratch and push my changes in a nice manner
Not sure if it helps anyone or even if it was the same issue, but I was finding the lovelace buttons action "toggle" wasn't working because the status of the entities (heat/cool/windscreen) was "unknown" or the like, so HA didn't know which way to toggle it.
If I looked in the entities list and explicitly turned them ON, it worked fine. So I created some scripts.yaml and called them in the lovelace card instead:
`# scripts.yaml
toggle_phev_cool: alias: Toggle PHEV Cool sequence: - choose: - conditions: - condition: state entity_id: switch.phev_cool state: 'on' sequence: - service: switch.turn_off target: entity_id: switch.phev_cool default: - service: switch.turn_on target: entity_id: switch.phev_cool mode: single
toggle_phev_heat: alias: Toggle PHEV Heat sequence: - choose: - conditions: - condition: state entity_id: switch.phev_heat state: 'on' sequence: - service: switch.turn_off target: entity_id: switch.phev_heat default: - service: switch.turn_on target: entity_id: switch.phev_heat mode: single
toggle_phev_windscreen: alias: Toggle PHEV Windscreen sequence: - choose: - conditions: - condition: state entity_id: switch.phev_windscreen state: 'on' sequence: - service: switch.turn_off target: entity_id: switch.phev_windscreen default: - service: switch.turn_on target: entity_id: switch.phev_windscreen mode: single `
` # On the lovelace Card
type: horizontal-stack cards:
-
type: button show_name: false show_icon: true entity: switch.phev_cool icon: mdi:air-conditioner tap_action: action: call-service service: script.toggle_phev_cool
-
type: button show_name: false entity: switch.phev_heat icon: mdi:car-seat-heater tap_action: action: call-service service: script.toggle_phev_heat
-
type: button show_name: false entity: switch.phev_windscreen icon: mdi:wiper tap_action: action: call-service service: script.toggle_phev_windscreen `
Note the lovelace card uses tap_action and is still the original entity so that it shows state (On will be lit up, everything else won't be, exactly as required)