Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
how_to:lirc:integration_with_home_assistant [2019/03/30 16:09]
franzunix
how_to:lirc:integration_with_home_assistant [2019/03/30 20:05] (current)
Line 1: Line 1:
 ====== Integration with Home Assistant ====== ====== Integration with Home Assistant ======
  
-# Reference guide +See the Home Assistant documentation of the [[https://​www.home-assistant.io/​components/​lirc/​|LIRC component]] to have a more details. If you wont that Home Assistant recognize the press of a specific button of your remote, you have to add the button and the remote name in the .lircrc file located in /​home/​homeassistant/​.\\ 
-https://​www.home-assistant.io/​components/​lirc/​+The .lircrc file is accessible [[system_administration:​common_operation:​connect_to_samba_share|via samba]].
  
-# Create a .lircrc ​in /​home/​homeassistant/​.lircrc ​(via samba) with the following lines+See this example of entry in the .lircrc ​file: 
 +<file text /​home/​homeassistant/​.lircrc>
 begin begin
     remote = SONY     remote = SONY
Line 11: Line 12:
     config = see-this     config = see-this
 end end
 +</​file>​
 +Add an entry for every button that you wont to be recognized. The button can be associated later to an automation.
  
-# Add an entry for every button ​that you wont to be recognizedThe button can be associated later to an automation+The values you set for the field "button" must be the same as in the lircd.conf file as well as the "​remote"​ name.
  
-The values you set for button must be the same as in the lircd.conf as well as the remote name+The values you put in the "​config"​ field will be the sensor value in Home Assistant when you press the button.
  
-the values you put for config entry will be the sensor value in Home Assistant ​when you press the button+Restart lirc to load the changes. 
 +<​cli>​ 
 +pi@d-diot:~ $ sudo systemctl restart lircd 
 +</​cli>​ 
 +Test your LIRC installation before proceeding by running:  
 +<​cli>​ 
 +pi@d-diot:~ $ sudo -u homeassistant -H -s 
 +homeassistant@d-diot:/​home/​pi $ ircat home-assistant 
 +</​cli>​ 
 +At every press of KEY_1 in the SONY remote a line should appear. Switch back to user "​pi"​ and restart ​Home Assistant 
 +<​cli>​ 
 +homeassistant@d-diot:/​home/​pi $ exit 
 +pi@d-diot:~ $ sudo systemctl restart home-assistant@homeassistant 
 +</​cli>​ 
 +Now every time you press button ​defined in the .lircrc, the LIRC component fires ir_command_received events on the bus. You can capture the events and respond to them in an automation script. See the [[https://​www.home-assistant.io/​components/​lirc/​|LIRC component]] documentation to learn more.
  
-# Restart lirc +===== Use the RESTful API of lirc_web =====
-$ sudo systemctl restart lircd+
  
-# Test your LIRC installation before proceeding by running +If you wont to send an IR command directly from Home Assistant, that is useful when you are on a remote connection where the lirc_web interface is not accessible, you can use the built in [[https://​github.com/​alexbain/​lirc_web#using-the-json-api|RESTful API of lirc_web]].
-$ ircat home-assistant +
-At every press of KEY_1 in the SONY remote a line should appear+
  
-# Restart ​home-assistant +To do this you have to configure the [[https://​www.home-assistant.io/​components/​rest_command/​|RESTful Command]] component of Home Assistant. For every remote key add an entry in the configuration.yaml (or in a different file with a split configuration) as in the example below: 
-$ sudo systemctl restart ​home-assistant@homeassistant +<file yaml /home/homeassistant/​.homeassistant/​configuration.yaml>​ 
- +Example configuration.yaml entry 
-# Now every time you press a button ​defined in the .lircrc the LIRC component fires ir_command_received events on the busYou can capture ​the events and respond ​to them in automation scripts like this+rest_command:​ 
- +  lirc_web_YOUR_REMOTE_YOUR_KEY:​ 
-# Example configuration.yaml automation entry +    url: '​http://​localhost:​3000/​remotes/​YOUR_REMOTE/​YOUR_KEY'​ 
-automation+    method: POST 
-  ​- aliasOff on Remote +</​file>​ 
-    ​trigger+Substitute YOUR_REMOTE and YOUR_KEY according to your needs. To see the list of remote and buttons as configured in lirc_web, go to: 
-      ​platformevent +  * http://​d-diot.local:​3000/​remotes.json 
-      ​event_typeir_command_received +  
-      ​event_data+Now you can create ​momentary switch for the remote ​button ​with the [[https://​www.home-assistant.io/​components/​switch.template/​|template switch platform]], adding the lines under the oled switch ​to the switches.yaml file
-        ​button_namesee-this +<file yaml /​home/​homeassistant/​.homeassistant/​switches.yaml 
-    ​action+# Template switches 
-      service: ​homeassistant.turn_off +- platformtemplate 
-      entity_id: ​group.a_lights +  ​switches
- +    ​oled
-# The button_name data values (e.g., see-this) are set by you in the .lircrc file.+      ​friendly_name"​Status"​ 
 +      ​value_template"{{ is_state('​binary_sensor.oled_status',​ '​on'​) }}" 
 +      ​turn_on
 +        ​serviceshell_command.start_oled 
 +        data: 
 +          entity_id: binary_sensor.oled_status 
 +      ​turn_off: 
 +        ​service: ​shell_command.stop_oled 
 +        ​data:​ 
 +          ​entity_id: ​binary_sensor.oled_status 
 +    ​lirc_web_YOUR_REMOTE_YOUR_KEY:​ 
 +      ​friendly_name:​ "Arrow up" 
 +      value_template:​ "​false"​ 
 +      turn_on: 
 +        service: rest_command.lirc_web_YOUR_REMOTE_YOUR_KEY 
 +      turn_off: 
 +        service: rest_command.lirc_web_YOUR_REMOTE_YOUR_KEY 
 +</​file>​ 
 +Once the switch is created ​you can add them in the webui as an entity button card for example.
  • how_to/lirc/integration_with_home_assistant.1553962146.txt.gz
  • Last modified: 2019/03/30 16:09
  • by franzunix