Closed patricknitsch closed 11 months ago
I made a test with the Esphome-native-api from twocolors. I got the following issue. So the Select Entity must therefore be integrated into the adaptier
https://github.com/twocolors/esphome-native-api/issues/22
@SimonFischer04: I saw you made a lot of fixes. Can you also integrate this in ?
could you please provide a full config yaml (if possible without tuya requirement as I don't have one here).
using the one provided i just get:
Thanks for your fast answer. Here is a complete config yaml with select part. All without tuya. Hope it can help you. If you need something other I try to support you.
#---------------------------------CONFIGURATION---------------------------------#
substitutions:
device_name: tank
friendly_name: tank
device_description: ESP8266
do_red_led: GPIO4 #D2
do_blue_led: GPIO0 #D3
do_green_led: GPIO5 #D1
do_relais_teich: GPIO2 #D4
do_relais_pump: GPIO14 #D5
do_trigger: GPIO13 #D7
di_echo: GPIO12 #D6
esphome:
name: ${device_name}
comment: ${device_description}
platform: ESP8266
board: esp8285
esp8266_restore_from_flash: true
on_boot:
- switch.turn_off: switch_pump_tank
- switch.turn_off: switch_pump_teich
# Enable logging
logger:
# Enable API
api:
password: "ZHBnoIGSRMwfmsVOVDn8l1//kEBdxLlUwlxzimR4zio="
# Enable over-the-air updates
ota:
password: "60414035211236a04d0b6c256d26e2ea"
# WiFi connection
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
ap:
ssid: "Tank Fallback Hotspot"
password: "urIkP8hgNFD9"
ap_timeout: 1min
use_address: ${device_name}
captive_portal:
# Sync time with Home Assistant
time:
- platform: homeassistant
id: homeassistant_time
# Text sensors with general information
text_sensor:
# Version
- platform: version
name: Version
# Wifi
- platform: wifi_info
ip_address:
name: IP Address
# Uptime formatted
- platform: template
name: Uptime
update_interval: 30s
icon: mdi:clock-start
lambda: |-
int seconds = (id(Uptime).state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
if ( days ) {
return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( hours ) {
return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else if ( minutes ) {
return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
} else {
return { (String(seconds) +"s").c_str() };
}
# Global Variables
globals:
- id: maxtime
type: int
restore_value: yes
initial_value: '600000'
#---------------------------------CONFIGURATION---------------------------------#
#-----------------------------------EXECUTION-----------------------------------#
sensor:
# Uptime sensor
- platform: uptime
id: Uptime
# WiFi Signal sensor
- platform: wifi_signal
name: Wifi Signal
update_interval: 10s
# Internal Voltage
- platform: adc
pin: VCC
name: Internal Voltage
# Ultrasensor
- platform: ultrasonic
trigger_pin: ${do_trigger}
echo_pin: ${di_echo}
name: Ultrasonic Sensor
id: ultrasonic_sensor
unit_of_measurement: "Liter"
accuracy_decimals: 0
update_interval: 60s
filters:
- lambda: return (1-(x/.82))*1600;
- filter_out: nan
switch:
# Switch to restart the plug
- platform: restart
name: Restart Switch
#Switch Pump Tank
- platform: output
name: Pumpe Tank
id: switch_pump_tank
output: relay_pump
on_turn_on:
- if:
condition:
sensor.in_range:
id: ultrasonic_sensor
below: 250
then:
- switch.turn_off: switch_pump_tank
- switch.turn_on: switch_pump_tank
- delay: !lambda return id(maxtime);
- switch.turn_off: switch_pump_tank
# Switch Pump Teich
- platform: output
name: Pumpe Teich
id: switch_pump_teich
output: relay_teich
on_turn_on:
- switch.turn_on: switch_pump_teich
- delay: !lambda return id(maxtime);
- switch.turn_off: switch_pump_teich
select:
- platform: template
name: "Template select"
optimistic: true
options:
- one
- two
- three
initial_option: two
output:
# Relais Pump
- id: relay_pump
platform: gpio
pin: ${do_relais_pump}
inverted: true
# Relais Teich
- id: relay_teich
platform: gpio
pin: ${do_relais_teich}
inverted: true
# Red LED
- platform: esp8266_pwm
id: output_red
pin: ${do_red_led}
max_power: 100%
# Green LED
- platform: esp8266_pwm
id: output_green
pin: ${do_green_led}
max_power: 100%
# Blue LED
- platform: esp8266_pwm
id: output_blue
pin: ${do_blue_led}
max_power: 100%
light:
# RGB LED
- platform: rgb
name: Teich Light
id: light_teich
red: output_red
green: output_green
blue: output_blue
effects:
# Strobe Effekt
- strobe:
name: Strobe Effect
colors:
- state: true
brightness: 100%
red: 100%
green: 90%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
# Flicker Effekt
- flicker:
name: Flicker Effect
alpha: 95%
intensity: 1.5%
# Lambda
- lambda:
name: Custom Effect
update_interval: 2s
lambda: |-
static int state = 0;
auto call = id(light_teich).turn_on();
// Transition of 1000ms = 1s
call.set_transition_length(1000);
if (state == 0) {
call.set_rgb(1.0, 1.0, 1.0);
} else if (state == 1) {
call.set_rgb(1.0, 0.0, 0.0);
} else if (state == 2) {
call.set_rgb(0.0, 1.0, 0.0);
} else {
call.set_rgb(0.0, 0.0, 1.0);
}
call.perform();
state += 1;
if (state == 4)
state = 0;
on_turn_on:
- delay: !lambda "return id(maxtime);"
- light.turn_off: light_teich
#-----------------------------------EXECUTION-----------------------------------#
sorry if you mis-understand my last comment. but I meant a "MVP" (MINIMAL! - but still full enough to work. config yaml with select component [i don't care about all this other stuff here if it is not related to the issue])
Sorry my fault.
Here is a minimal config with select component.
esphome:
name: test
friendly_name: test
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
#encryption:
password: "xZ2gdgaB1U5dEX+6SGQ8XZuYeAHqUkYeY1UuBVx3I5Y="
ota:
password: "40e59c8bbc5f9ba27ba7f4fbed7b216f"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Test Fallback Hotspot"
password: "CWgUBLNdggaM"
captive_portal:
select:
- platform: template
name: "Template select"
optimistic: true
options:
- one
- two
- three
initial_option: two
maybe you are more familiar with esphome selects. After looking into this a bit I'm thinking about:
options:
- one
- two
- three
options:
0: Manual
1: Schedule
2: Holiday -> only for Koenighaus
how should this be handled in the adapter? should the object be of type number / string / ...?
The select option must be a string. ->option (Required, string,) The tuya select works a little bit other. The option works as mapping. See a part of the doc: ->options (Required, Map[int, str]):
Yea i did read both docs. The issue is that both are "type: select". So if i implement it as string, your initial tuya issue wont be solved. And if i do it the "tuya-map way" another issue will follow soon with tenplate select. (Not to talk about the modbus select... That will come up also probably at some point and is different again...)
Basically thinking out loud and hoping to get input about how to implement this properly.
Is it really required to specifically differenciate between platform and then ALWAYS do:
?
I understand. That´s a lot of work. Maybe @DutchmanNL has any ideas else as main developer.
I checked a work around to control the tuya select with the normal select component. It looks like it works. So I think,, it will be the best to integrate the normal select component. This would help the most user.
I think I got something. Can you please test by directly installing the adapter from URL https://github.com/SimonFischer04/ioBroker.esphome/tree/fix/169
. Preferable not on your main system but a dedicated Test-System!
@patricknitsch
@patricknitsch can you please test the proposed fix ?
Sure. I will test it today and give you feedback.
Made a Test in a Testsystem. I got no errors or warnings.(Only error was from the integrated dashboard. See the picture below)
the select component were accepted and the configured values were displayed correctly. See the picture below. Good job!
@patricknitsch great Thank you
@SimonFischer04 nice job!
About the dashboard its related to an missing Directory which should be created at install or first run
Will inclusie that before making a new Version with this fix
If all goes well I will be able to do that somewhere end of today
Beca or Koenighaus thermostats with Tuya Protocol send a datapoint from type ENUM. This datapoint has these values: 0: Manual, 1: Schedule and on Koenighaus 2: Holiday.
@DutchmanNL : Is there an opinion to integrate the select mode in the ESP Home Adapter?
Many thanks for supporting.