nabaztag2018 / pynab

Nabaztag en Python pour RaspberryPi
GNU General Public License v3.0
158 stars 54 forks source link

first test of MQTT integration #449

Open 14roiron opened 1 year ago

14roiron commented 1 year ago

First test to introduce MQTT The aim is to introduce commandability from Home assistant and others It is easier to use MQTT that a Stateful TCP connection I will refactor also the code to use only one MQTT client instead of 2 And I will need to write some tests Thanks

Madelena commented 1 year ago

Any updates on this?

14roiron commented 1 year ago

If you have any interest in it, you should have a look here https://github.com/nopap/nab2mqttd this version is better implementation than mine

14roiron commented 1 year ago

If you use this depot in home assistant https://github.com/14roiron/media_player.template/tree/master/custom_components/media_player_template plus this config,

media_player:
  - platform: media_player_template
    media_players:
      receiver:
        friendly_name: Nabztag
        device_class: receiver
        value_template: "on"
        turn_on:
        turn_off:
        play_media:
          service: mqtt.publish
          data:
            topic: tagtag/rcv
            payload_template: '{"type":"message","signature":{"audio":["nabmastodond/respirations/*.mp3"]},"body":[{"audio":["{{ media_id }}"]}]}'

you can send a TTS message to the nabaztag

  - service: tts.cloud_say
    data:
      entity_id: media_player.receiver
      message: Hello Lapinou

If you have questions, I could make a post on the forum