monster1025 / aqara-mqtt

Aqara (Xiaomi) Gateway to MQTT bridge (I use it for home assistant integration)
Apache License 2.0
88 stars 21 forks source link

Question regarding HA setup of switch #5

Closed WoodsterDK closed 6 years ago

WoodsterDK commented 7 years ago

Hi there, Do you have an example of configuring the switch as a input withou coupling it to a automation directly. Is it possible to assign a friendly name to each each type of click?

WoodsterDK commented 7 years ago

And what about the sensor battery level - how do you handle that?

monster1025 commented 7 years ago

Here is battery level sensor example:

sensors:
- platform: mqtt
  state_topic: 'home/switch/bath/status'
  name: 'switch_bath_voltage'
  value_template: "{{ (100-((3300 - float(value)) / (3300 - 2800)) * 100) | round(0) }}"
  unit_of_measurement: '%'

Do you have an example of configuring the switch as a input withou coupling it to a automation directly, this is only one method to handle 'events' (not state change) that I know in HA (but my skills in HA are not so good =) ).

I am using it as it specified in README:

trigger:
    platform: mqtt
    topic: home/switch/hall/status
    payload: 'click'
action:
  service: script.hall_force_light_on
WoodsterDK commented 7 years ago

Yes, but that gives another sensor... Perhaps it is possible to make a customized mqtt sensor, that utilizes the attribute battery level...

monster1025 commented 7 years ago

I don't have such implementation and don't have enough skill to write it for HA.

WoodsterDK commented 7 years ago

Ok, I will see if i can do it.... will get back if you are interested.

WoodsterDK commented 7 years ago

Hi again, for a quick solution, I ended up adding additional sensors, and it seems to work quite well. Something different: Are you having ghost events from the door and movement sensor, as someone notices in the HA forum?

monster1025 commented 7 years ago

Hi.

No, i haven't any ghost events - only udp event miss (event is executed only by polling sensor - my setup polls all sensors every 2 seconds).

WoodsterDK commented 7 years ago

Does 2sec polling not decrease battery life?

monster1025 commented 7 years ago

No, because it polling gateway - not sensors.

WoodsterDK commented 7 years ago

Are you sure, no heavy battery use/drain?

monster1025 commented 7 years ago

100% sure, I use it in my setup for ~2 month.