I don’t think the automation structure is the problem (when using the automation editor in HA the structure is completely different than in the examples).
I think that the problem is that MQTT it’s not running or the address is incorrect (“No route to host”).
Afterwards, there might be a problem with the trigger of the automation. Using a binary sensor as a trigger, it needs an “on” payload and an “off” payload to be able to switch from off to on, however it needs to have someone (or something) sending these two payloads. The “on” payload is simple, is sent by Hue sensor when motion is detected. However, as I think the Hue sensor doesn’t also send the “off” payload, you need to provide it.
Does the Hue sensor send also the off payload? Otherwise, the binary sensor state will be all the time “on”.
Do you need help setting up the automation for setting the binary sensor to off?
I am pretty sure that MQTT is running because all my other automations with the hue motion sensor work fine (I followed a tutorial on github to set it up with mqtt).
Also, I pinged the tablets ip address and its fully reachable.
The motion sensor switches some (non hue) lights on and off, so I guess it does send an “off” payload.
Just to be sure I didn’t mess anything else, due to my limited knowledge of basically everything about mqtt: is there anything special I need to add to the configuration.yaml?
This explains why you have connectivity issues with some of the commands - you need to address your messages and commands to the broker, not any individual client. And on the tablet you need to connect it to your broker IP. So you should subscribe (ie run this command from your pi’s command line and watch the result) by:
mosquitto_sub -h 192.168.0.12 -t "#" -v
Then activate the motion sensor and you should see your JSON payload get published to the broker and displayed in the terminal window.
My guess at this point is that your tablet isn’t connected to the broker, so it’s not picking up any messages, but the above test will confirm at least whether HA is properly publishing the message.