/ September 13, 2018/ Articles, Home Assistant, MQTT/ 1 comments

  1. 1. Flash a Wemos D1 mini with Tasmota software en attach the Battery Shield to it.

2. I have bought an 2100 mAh Li-Ion battery and connected it.

3. Flash Tasmota on it. I used the Sonoff.bin and the Windows Flash Tool for it
4. Configured MQTT and setup TelePeriod to 60 sec
Using the LWT Online message as a state_topic, when the unit comes online, the topic is send over MQTT to HA.

5. Setup HA with MQTT and the following sensors:

# AUTO PRESENCE
  - platform: mqtt
    name: "Auto"
    icon: mdi:car-connected
    state_topic: "tele/Auto/LWT"
    qos: 1
    value_template: >
      {% if value == "Online" %}
      Aanwezig
      {% else %}
      Afwezig
      {% endif %}
# AUTO PRESENCE SENSOR DETAILS
  - platform: mqtt
    name: "Auto Uptime"
    icon: mdi:camera-timer
    state_topic: "tele/Auto/STATE"
    availability_topic: "tele/Auto/LWT"
    qos: 1
    payload_available: "Online"
    payload_not_available: "Offline"
    value_template: "{{ value_json.Uptime | replace('T',' dagen ') }}" 
    json_attributes:
      - Time
      - Uptime
      - Vcc
      - Wifi

Setup custom sensors:

auto_battery:
        friendly_name: 'Auto Batterij' 
        unit_of_measurement: 'V'
        value_template: >
            {%- if states.sensor.auto.state == 'Aanwezig' %}
                {{ states.sensor.auto_uptime.attributes.Vcc|round(2) }}
            {% else %}
                0
            {%- endif %}
        icon_template: mdi:battery-charging
      auto_wifi_signal:
        friendly_name: 'Auto Wifi Signaal' 
        unit_of_measurement: '%'
        value_template: >
            {%- if states.sensor.auto.state == 'Aanwezig' %}
                {{ states.sensor.auto_uptime.attributes.Wifi.RSSI|round }}
            {% else %}
                0
            {%- endif %}
        icon_template: mdi:signal-cellular-2

Now we have a presence detection for the Car.

You could build automations for example:

- alias: Notify Car
  initial_state: on
  trigger:
    - platform: state
      entity_id: sensor.auto
      to: 'Aanwezig'
  action:
    - service: notify.ios_iphone
      data_template:
        title: 'Welkom home!'
        message: >
                 Car is home!

Edit: because of Battery drain i have stopped with the presence detection. When i can solve this, i will continue with the project.

Share this Post

1 Comment

  1. Hi, I literally just randomly came across this, but you could tap power from the car. Much safer than driving around with a battery in a hot car and no drainage issues. 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
*
*