ESP‐360‐REMOTE - aancel/admin GitHub Wiki
From 0 to IR remote using ESP-360-REMOTE
Pre-requisites
- A working instance of Home assistant
- A computer (Linux) with docker installed
Run the ESP-home container
- Run the following command in a terminal to launch ESPHome:
sudo docker run -ti \
--rm \
--volume config:/config \
--volume /etc/localtime:/etc/localtime:ro \
--privileged \
--network "host" \
--env "USERNAME=test" \
--env "PASSWORD=test" \
ghcr.io/esphome/esphome:2024.12.2
Start esphome for initial configuration
-
Connect ESP-360-Remote on your computer via USB
-
Connect to http://127.0.0.1:6052, using a Chrome-based browser (required for the device to be recognized)
-
If you want to start from 0, e.g you must reinit the encryption key:
- Delete the current device
- Then click add new device and select the port on which the device is connected on your computer
- The device will be reinstalled. It might take a few moments.
-
Click on edit and copy the
esphome.api.encryption.key
value. -
Paste the following content inside the configuration file currently being edited:
esphome:
name: esp360-default-1
friendly_name: ESP360-default-1
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
api:
encryption:
key: "*** TO REPLACE ***"
actions:
- action: send_ir_raw
variables:
command: int[]
then:
- remote_transmitter.transmit_raw:
transmitter_id: IR_TX
code: !lambda 'return command;'
- action: send_rf_raw
variables:
protocol_number: int
raw_data: string
then:
- remote_transmitter.transmit_rc_switch_raw:
transmitter_id: RF_TX
protocol: !lambda 'return esphome::remote_base::RC_SWITCH_PROTOCOLS[protocol_number];'
code: !lambda 'return raw_data;'
ota:
platform: esphome
password: ""
wifi:
ssid: "*** TO REPLACE ***"
password: "*** TO REPLACE ***"
#HotSpot when it can't connect to WiFi
ap:
ssid: "Esp360Remote"
password: "Esp360Remote"
captive_portal:
#i2c bus definition
i2c:
sda: 21
scl: 22
scan: true
id: bus_a
# Offsets have been added to the measurements taken.
# These are necessary due to the heat generated by the PCB, the second layer of the board, and the case.
# This way, sufficiently accurate values are obtained for automations
sensor:
- platform: shtcx
temperature:
name: "Temperature"
filters:
- median:
window_size: 5
send_every: 1
- offset: -3.7
humidity:
name: "Humidity"
filters:
- median:
window_size: 5
send_every: 1
- offset: +19.1
address: 0x70
update_interval: 300s
- platform: bh1750
name: "BH1750 Illuminance"
filters:
- multiply: 5
address: 0x23
update_interval: 1s
#Setting up IR and RF receivers
remote_receiver:
- id: RF_RX
pin:
number: GPIO5
inverted: True
dump:
- rc_switch
tolerance: 35%
filter: 200us
idle: 4ms
buffer_size: 10kb
on_rc_switch:
- homeassistant.event:
event: esphome.rf_code_received
data:
protocol: !lambda 'return x.protocol;'
code: !lambda 'return x.code;'
- id: IR_RX
pin:
number: GPIO19
inverted: True
dump: all
on_raw:
- homeassistant.event:
event: esphome.ir_raw_code_received
data:
code: !lambda '
reverse(x.begin(), x.end());
std::string str = "";
for (auto it = x.begin(); it != x.end(); ++it)
{
str += to_string(*it);
str += ",";
if (it != x.end() - 1) str += " ";
}
if (str.size() > 0) str.erase( str.end() - 2);
return esphome::to_string("[" + str + "]");'
on_pronto:
- homeassistant.event:
event: esphome.ir_pronto_code_received
data:
code: !lambda 'return x.data;'
on_lg:
- homeassistant.event:
event: esphome.ir_lg_code_received
data:
data: !lambda 'return x.data;'
nbits: !lambda 'return x.nbits;'
on_panasonic:
- homeassistant.event:
event: esphome.ir_panasonic_code_received
data:
address: !lambda 'return x.address;'
command: !lambda 'return x.command;'
#Setting up IR and RF transmitters
remote_transmitter:
- id: RF_TX
pin: GPIO18
carrier_duty_percent: 100%
- id: IR_TX
pin: GPIO13
carrier_duty_percent: 50%
web_server:
port: 80
# Status LED
switch:
- platform: gpio
pin: 12
name: "Status Led"
restore_mode: ALWAYS_ON
- Edit the following fields:
- Set the
esphome.api.encryption.key
value to the one you copied - Set the
wifi.ssid
andwifi.password
values to the ones of your wifi network
- Set the
- Then click the install button
- Then "Plug into this computer" to set up the already plugged device
- The installation will take a few moments.
Connect the device to Home-Assistant
-
Find the device IP on your network (via your router)
-
Connect to it by typing its IP address in a browser
-
You should be greeted with the ESP home page
-
In Home-Assistant -> Settings -> Devices & Services, add the ESP-Home integration:
- Set the device IP on your network, leave the default port (6053), and submit
- Then set the key to the
esphome.api.encryption.key
value you previously copied - And you should be set
Adding new IR devices
- Connect to your device by typing its IP address in a browser
- You should get a log window on the right
- Point the remote you want to emulate towards ESP-360-REMOTE
- Click the button you want to emulate and quickly check the logs
- You should see entries such as:
...
Received NEC: address=0x7F80, command=0xFA05 command_repeats=1
...
Received Samsung: data=0xE0E040BF, nbits=32
...
- To emulate these actions, you will need to add actions corresponding to the device in the
api.actions
section of the previously edited yaml file, e.g. for the previous actions:
api:
# ...
actions:
# ...
- action: send_hdmi_switch_1
then:
- remote_transmitter.transmit_nec:
transmitter_id: IR_TX
address: 0x7F80
command: 0xFA05
# ...
- action: send_tv_power
then:
- remote_transmitter.transmit_samsung:
transmitter_id: IR_TX
data: 0xE0E040BF
# ...
- Then click the install button
- Then "Plug into this computer" to set up the already plugged device
- The installation will take a few moments, and the device will be ready to use the new commands in Home-Assistant
Add a button card in Home Assistant
In Home-Assistant:
- Add button card
- Clear out entity if filled
- Set name field
- In 'Tap behavior', select 'Perform action'
- In 'Action', search and select the action you added (should start with esphome)