fribse
(Kenneths Teknik)
September 14, 2019, 8:52pm
1
I have a Sonoff Basic with ESPHome in it, that I’m using to control a light. In HA it’s registered as a switch, is there a way to have it register as a light instead?
My current config looks like this:
esphome:
name: gang
platform: ESP8266
board: esp01_1m
wifi:
ssid: SSID
password: NotShown
api:
logger:
baud_rate: 0
ota:
password: "VerySecret"
time:
- platform: homeassistant
id: homeassistant_time
text_sensor:
- platform: version
name: "Gang ESPHome Version"
- platform: wifi_info
ip_address:
name: "Gang ip"
ssid:
name: "Gang ssid"
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Gang Sonoffc Button"
on_press:
- switch.toggle: relay
switch:
- platform: gpio
name: "Gang"
pin: GPIO12
id: relay
status_led:
pin:
number: GPIO13
inverted: yes
But it is a switch and not a light. Lights generally have colour and dim capabilities, switches are on and off.
You can change the icon of the identity so it is more recognizable if you want.
1 Like
VDRainer
(🍻)
September 15, 2019, 6:57am
3
You can use the Light Switch in HA, but it’s one more entity.
1 Like
fribse
(Kenneths Teknik)
September 15, 2019, 11:06am
5
Thankyou all three for the input!
Holdestmade:
Would this work ?
I think that would work, then I just need to figure out the output part, I can’t seem to get the syntax correct here
For now I’ve set it up with a lightswitch in HA, as per @VDRainer ’s suggestion.
glmnet
(Guillermo Ruffino)
September 15, 2019, 1:12pm
6
Let me google that for you
I have been using this example code from @frenck
The code works perfect, but i would like that the sonoff showed up in HA as a light, not switch (better for google assistant)
I still want all the “bells and whistles” (led status that is correct, the use of the physical button on the sonoff should work as in this example)
I know i can transform the switch in homassistant to a light, but i was thinking that this must be possible in the ESPHome yaml code itself.
I can figure out how to have the…
2 Likes
fribse
(Kenneths Teknik)
September 15, 2019, 1:57pm
7
Thankyou for the googling expertise
So, the resulting config is:
substitutions:
device_name: hallway
# Higher value gives lower watt readout
current_res: '0.00290'
# Lower value gives lower voltage readout
voltage_div: '940'
esphome:
name: '${device_name}'
platform: ESP8266
board: esp01_1m
wifi:
ssid: SSID
password: PASSWORD
api:
logger:
baud_rate: 0
ota:
password: "PASSWORD"
time:
- platform: homeassistant
id: homeassistant_time
text_sensor:
- platform: version
name: '${device_name} ESPHome Version'
- platform: wifi_info
ip_address:
name: '${device_name} ip'
ssid:
name: '${device_name} ssid'
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: '${device_name} Button'
on_press:
- light.toggle: lightbar
output:
- platform: gpio
id: relay
pin: GPIO12
light:
- platform: binary
id: lightbar
name: '${device_name}'
output: relay
status_led:
pin:
number: GPIO13
inverted: yes
sensor:
- platform: uptime
name: '${device_name} Uptime'
unit_of_measurement: days
update_interval: 300s
accuracy_decimals: 1
filters:
- multiply: 0.000011574
- platform: wifi_signal
name: '${device_name} WiFi Signal'
accuracy_decimals: 0
update_interval: 300s
I can see that in the example the !secret method is used, but if I try that, it will not compile, so is that not through ESPHome?
2 Likes
glmnet
(Guillermo Ruffino)
September 15, 2019, 3:31pm
8
Secrets is a method to store passwords and alike in another file.
secrets.yaml
1 Like
fribse
(Kenneths Teknik)
September 15, 2019, 3:50pm
9
Yes, I’m using it already in my normal configs, but when I use it in ESPHome I get errors marked?
glmnet
(Guillermo Ruffino)
September 15, 2019, 3:53pm
10
If you want to use secrets.yaml in ESPHome you have to create another secrets.yaml file next to your normal configuration files. If you are on hassio I don’t know if it is supported on the dash board directly or you have to put the file with another means like the configurator add on.
1 Like
nickrout
(Nick Rout)
September 25, 2019, 6:54am
11
A symlink should work if you want to keep all your secrets in one place.
1 Like
fribse
(Kenneths Teknik)
September 25, 2019, 7:36am
12
It doesn’t look like it, which is a bummer, I really want to keep it in Hass.io , trying to keep it manageble, at least somewhat, by others than just me.
@nickrout , ok, that would make it much cleaner, if just the editor supported it
glmnet
(Guillermo Ruffino)
September 25, 2019, 4:00pm
13
1 Like