I have a Pi-Core music player on my network that is turned on and off using a smart socket (it runs in memory and the storage is read only). I can control the socket without any problems using the Home Assistant Interface, on my phone or computer.
I’m in the process of adding an additional USB keypad, that gives me 12 keys that I can use to trigger actions on my computer, that I frequently carry out. These load applications, act as a shortcuts for key combinations and one shuts down my MagicMirror device, using a single key.
I want to set up a key to toggle the state of my Pi-Core player smart socket (Meross), and was planning to use MQTT to do this.
I installed the Mosquitto broker and have set it up with an account.
I have written a simple executable (C++ using the Mosquitto library) that will broadcast a topic of player/cmd
with a payload of toggle
every time it is run. It runs on desktop PC (Linux).
If I go into the MQTT settings and Listen to a topic on player/cmd
, I get the payload of toggle
, so the MQTT broker is receiving the messages that I am sending it.
If I look in the Mosquitto Broker logs, I see my software is making a New connection, that there is a New Client connected and it shows the clients user name (the one I set up for use with the broker). It then disconnects.
In the Home Assistant Log screen, I only see the action when I run it manually within Home Assistant and it works without fail.
I have set up an automation that I think should trigger the toggling on my smart socket and it does if I run the Action within Home Assistant (so the actions section of the yaml works).
alias: Toggle Music Player State
description: ""
triggers:
- trigger: mqtt
topic: player/cmd
payload: toggle
conditions: []
actions:
- type: toggle
device_id: 7bdc89348112e27e40afbc15ecf0707a
entity_id: 54a42928ec120a2c854a9f25115cb369
domain: switch
mode: single
The automation action isn’t triggered, so I’m thinking there is something missing between the Mosquitto broker and the Automation, I’m sure I’m doing something daft/have missed out a step, but I can’t see it. Any assistance would be appreciated.