MQTT input into Home Assistant

Hi
I’m trying to get presence data from my 3 Hue motion sensors into Home Assistant. I’m not sure what the best way is to get in or the best way to hold it in HA.
I’m sending it via MQTT to an input_slider, but I can’t get it to work. I’m using this example, Setting input_slider value from mqtt topic
Tried both variation.
sensor:
- platform: mqtt
state_topic: ‘wc/motion/presence/’
name: ‘wc_motion’
value_template: ‘{{ value.state }}’
#value_template: ‘{{ value_json.state }}’

Seperat file; automations.yaml (other automation works).

- alias: WC Motion
  trigger:
    platform: mqtt
    topic: "wc/motion/presence/"
  action:
    service: input_slider.select_value
    data_template:
      entity_id: input_slider.wc_motion
      value: '{{  states.sensor.wc_motion.state }}'

I know the MQTT broker works. I can see the data on phone and tablet, both change right away. I tried sending with or without decimal "2, “2.2”, or “2,2”.
I get the error:
[homeassistant.core] Invalid service data for input_slider.select_value: expected float for dictionary value @ data['value']. Got ''

Second question. The Hue Motion sensors also got temperature data i want to display. What is the best way to display a decimal integer? Can something be used a a text box or similar?

Thanks
/Lars

I have mine going to MQTT binary sensors. On means there is motion and off means no motion. I’m not sure why you want to use a slider?

  kitchen_motion_sensor:
      binary_sensor:
        - platform: mqtt
          state_topic: "mygateway1-out/13/1/1/0/16"
          name: "motion_sensor_13_1"
          payload_on: 1
          payload_off: 0
          device_class: motion

The temperature sensors would be just MQTT sensors, with a unit of measurement

  - platform: mqtt
    state_topic: "/energenie/eTRV/Report/Temperature/329"
    name: "Lounge Temperature"
    unit_of_measurement: "°C"
    force_update: true
    expire_after: 660
1 Like

Hi
Thanks for reply. I used sliders, because i had another example i tried to get working. But the sensors is more simple, so that’s perfect.
Real time data isn’t important to me. I’m interested in how many hours since a sensor registered any motion. I haven’t used HA long. My original plan is to get the data from the Hue sensors with a Python script and let the script parse to HA that its 5 hours since any motion. You tried to used the Home Assistants History for checking how many hours its been since something?

If you want to use Python with HA I strongly suggest you check out Appdaemon.

Writing an appdaemon app that does something after five hours of no motion is relatively simple

import appdaemon.appapi as appapi

class motion_app(appapi.AppDaemon):
    def initialize(self):
         # Listens for 'motion_sensor' to be in state 'off'' for 5 hours,
         # then calls method 'motion_stopped'
          self.listen_state(self.motion_stopped, binary_sensor.motion_sensor],
                new = "off",
                duration = 5*60*60)

    def motion_stopped(self, entity, attribtute, old, new, kwargs):
        # Do whatever you need here

The details of the api are here

Great, I’ll check it out. Thanks for the help.

/Lars