Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: nicer MQTT discovery #21

Closed
poudenes opened this issue Nov 18, 2021 · 10 comments
Closed

Feature request: nicer MQTT discovery #21

poudenes opened this issue Nov 18, 2021 · 10 comments

Comments

@poudenes
Copy link

poudenes commented Nov 18, 2021

Hi,

Would it be nicer to add:

"device": {"identifiers": "toogood_togo","name": "Toogood To Go","manufacturer": "MaxWinterstein"},

to the discovery part?

When you have this all entities will be combine together as a "Device" and when you click on the name you see all the entities.

Its a glitch upgrade :)

Then you will get this (example)
Screenshot 2021-11-18 at 12 14 36

Upper left you see then: Toogood To Go.
Below you see then "by MaxWinterstrein"
And richt the entities in a list.

@DavyRoswinkel
Copy link

Nice but it would be even nicer if it worked......Stopped working here, and I think there will not be a solution in the near future.
It was such a nice job Max did...

@poudenes
Copy link
Author

What I know (tried myself) delete the entities and add them clear. It will work. Rest of the discovery will be the same.
Only this will add so it will become under "device"...

@poudenes
Copy link
Author

poudenes commented Nov 18, 2021

Maybe create a beta version and try. I would open to help. Create a test HA and see how this will work.

main.py:

                {
                    "name": f"TooGoodToGo - {shop['display_name']}",
                    "icon": "mdi:food" if stock > 0 else "mdi:food-off",
                    "state_topic": f"homeassistant/sensor/toogoodtogo_{item_id}/state",
                    "json_attributes_topic": f"homeassistant/sensor/toogoodtogo_{item_id}/attr",
                    "unit_of_measurement": "portions",
                    "value_template": "{{ value_json.stock }}",
                    "unique_id": f"toogoodtogo_{item_id}",
                }

to:

                {
                    "name": f"TooGoodToGo - {shop['display_name']}",
                    "icon": "mdi:food" if stock > 0 else "mdi:food-off",
                    "device": {"identifiers": "toogood_togo","name": "Toogood To Go","manufacturer": "MaxWinterstein"},
                    "state_topic": f"homeassistant/sensor/toogoodtogo_{item_id}/state",
                    "json_attributes_topic": f"homeassistant/sensor/toogoodtogo_{item_id}/attr",
                    "unit_of_measurement": "portions",
                    "value_template": "{{ value_json.stock }}",
                    "unique_id": f"toogoodtogo_{item_id}",
                }

@MaxWinterstein
Copy link
Owner

Open to these changes, but sadly can't test it easily as I suffer from the blocked IP issue too...

@poudenes
Copy link
Author

Same issue here now also :(

@MaxWinterstein
Copy link
Owner

MaxWinterstein commented Dec 2, 2021

Having all these entities group under one device makes sense to me.

But it seems there is more needed than just this one line? I guess somewhere here:

result_state = mqtt_client.publish(
f"homeassistant/sensor/toogoodtogo_{item_id}/state",
json.dumps({"stock": stock}),

But out of time for today :(

@TerrorSource
Copy link

@MaxWinterstein how did you get the ip blocked?

I know the time slots for the favorite tgtg stores so im going to try to run the add-on only in the known timeslots, interval of 1 minute so only 60 polls a day

@niklas1375
Copy link

niklas1375 commented Feb 18, 2022

so im going to try to run the add-on only in the known timeslots, interval of 1 minute so only 60 polls a day

@TerrorSource that sounds like a good idea (e.g. to also have a break during the night). Did you manage to make it work?

Edit: with PR #35 and the cron type schedule it would be rather easy to schedule it more granularly. Hoping this will be accepted soon :)

@TerrorSource
Copy link

TerrorSource commented Feb 25, 2022

@niklas1375 i made 2 automations in HomeAssistant, 1 to start and 1 to stop.

Start:

alias: tgtg-start
description: ''
trigger:
  - platform: time
    at: '17:00'
condition: []
action:
  - service: hassio.addon_start
    data:
      addon: f1c878cb_tgtg-ha-mqtt-bridge
mode: single

Stop:

alias: tgtg-stop
description: ''
trigger:
  - platform: time
    at: '18:00'
condition: []
action:
  - service: hassio.addon_stop
    data:
      addon: f1c878cb_tgtg-ha-mqtt-bridge
mode: single

@Dielee
Copy link
Collaborator

Dielee commented Jun 18, 2022

This function is now released. Version > 2.2.0 includes the new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants