hmm… i read documentation whole day an i am unable to get it working is seems like value is not provisioned to hass
Show your code and as much error information as possible. Help us to help you.
esphome:
name: vasek-heater
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Vasek-Heater Fallback Hotspot"
password: ""
captive_portal:
output:
switch:
- platform: gpio
pin: 5
id: gpio_d1
- platform: gpio
pin: 4
id: gpio_d2
#climate:
# - platform: thermostat
# name: "Thermostat Climate Controller"
# sensor: my_temperature_sensor
# default_target_temperature_low: 20 °C
# min_heating_off_time: 300s
# min_heating_run_time: 300s
# min_idle_time: 30s
# heat_action:
# - repeat:
# count: 30
# then:
# - output.turn_on: gpio_d2
# - delay: 30ms
## - output.turn_on: gpio_d1
# - delay: 30ms
# - output.turn_off: gpio_d2
# - delay: 30ms
# - output.turn_off: gpio_d1
# - delay: 30ms
#- repeat:
# count: !lambda |-
# return id(some_sensor).state - 4.5;
# then:
# - output.turn_on: gpio_d1
# - delay: 30ms
# - output.turn_on: gpio_d2
# - delay: 30ms
# - output.turn_off: gpio_d1
# - delay: 30ms
# - output.turn_off: gpio_d2
# - delay: 30ms
#idle_action:
# - repeat:
# count: 30
## then:
# - output.turn_on: gpio_d2
## - delay: 30ms
# - output.turn_on: gpio_d1
# - delay: 30ms
# - output.turn_off: gpio_d2
# - delay: 30ms
# - output.turn_off: gpio_d1
# - delay: 30ms#
I am not even able to Compile and upload it basicaly how it should vork is folowing
on seting the temperature shoud run foloving code first to null the encoder
- repeat:
# count: 30
# then:
# - output.turn_on: gpio_d2
# - delay: 30ms
## - output.turn_on: gpio_d1
# - delay: 30ms
# - output.turn_off: gpio_d2
# - delay: 30ms
# - output.turn_off: gpio_d1
# - delay: 30ms
and then actual set of the temperature
- repeat:
# count: !lambda |-
# return id(some_sensor).state - 4.5;
# then:
# - output.turn_on: gpio_d1
# - delay: 30ms
# - output.turn_on: gpio_d2
# - delay: 30ms
# - output.turn_off: gpio_d1
# - delay: 30ms
# - output.turn_off: gpio_d2
# - delay: 30ms
where if understand correctly id(some_sensor).state should represent actual value of Celsius degree
ins there some funxtion liken in js like this.state whitch just retur selected temperature ?
Use the logger component and it’s logger.log action:
i tryed like 3 hours no luck i am sentence to frizze toi dead ESP Home is actually harder than using plain code at least for me
esphome:
name: vasek-heater
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Vasek-Heater Fallback Hotspot"
password: ""
captive_portal:
# Example configuration entry
globals:
- id: ch1s
type: float
restore_value: false
initial_value: "5.6"
sensor:
- platform: template
name: x
id: x
lambda: |-
return float(id(ch1s));
update_interval: 60s
output:
- platform: gpio
pin: 12
id: gpio_d1
- platform: gpio
pin: 13
id: gpio_d2
# Example single-point configuration entry (for heating only)
climate:
- platform: thermostat
name: "Thermostat Climate Controller"
sensor: x
default_target_temperature_low: 20 °C
min_heating_off_time: 300s
min_heating_run_time: 300s
min_idle_time: 30s
heat_action:
repeat:
count: !lambda |-
return 30 - 4.5;
then:
- output.turn_on: gpio_d1
- delay: 30ms
- output.turn_on: gpio_d2
- delay: 30ms
- output.turn_off: gpio_d1
- delay: 30ms
- output.turn_off: gpio_d2
- delay: 30ms
idle_action:
repeat:
count: 30
then:
- output.turn_on: gpio_d2
- delay: 30ms
- output.turn_on: gpio_d1
- delay: 30ms
- output.turn_off: gpio_d2
- delay: 30ms
- output.turn_off: gpio_d1
- delay: 30ms
I manage to get it working kinda but i still need to get actual degreees set to heater action and to senzor global variable ch1s any advise ?
Little progress on code almost vorking but my variable ch1s is not set and it stays 0
# Example configuration entry
globals:
- id: ch1s
type: float
restore_value: false
initial_value: "5.6"
sensor:
- platform: template
name: x
id: x
lambda: |-
return float(id(ch1s));
update_interval: 30s
output:
- platform: gpio
pin: 12
id: gpio_d1
- platform: gpio
pin: 13
id: gpio_d2
# Example single-point configuration entry (for heating only)
climate:
- platform: thermostat
name: "Thermostat Climate Controller"
id: temperature_sensor
sensor: x
default_target_temperature_low: 20 °C
min_heating_off_time: 300s
min_heating_run_time: 300s
min_idle_time: 30s
visual:
min_temperature: 0.5 °C
max_temperature: 30 °C
temperature_step: 0.5 °C
heat_action:
- repeat:
count: 30
then:
- output.turn_on: gpio_d2
- delay: 30ms
- output.turn_on: gpio_d1
- delay: 30ms
- output.turn_off: gpio_d2
- delay: 30ms
- output.turn_off: gpio_d1
- delay: 30ms
- repeat:
count: !lambda |-
return id(temperature_sensor).target_temperature - 4.5;
then:
- output.turn_on: gpio_d1
- delay: 30ms
- output.turn_on: gpio_d2
- delay: 30ms
- output.turn_off: gpio_d1
- delay: 30ms
- output.turn_off: gpio_d2
- delay: 30ms
idle_action:
repeat:
count: 30
then:
- output.turn_on: gpio_d2
- delay: 30ms
- output.turn_on: gpio_d1
- delay: 30ms
- output.turn_off: gpio_d2
- delay: 30ms
- output.turn_off: gpio_d1
- delay: 30ms
on_state:
- logger.log:
format: "The temperature set value %.1f virtual senzor %.1f"
args: [ 'id(temperature_sensor).target_temperature', 'id(x).state']
- globals.set:
id: ch1s
value: id(temperature_sensor).target_temperature
anny sugestion why ?
I am happy to see that you are homing in on a solution.
You don’t need a float() cast here. Your global is already of type float.
Just use
lambda: |-
return id(ch1s);
Hint:
When you would really need to parse a string to a float you would do: parse_number<float>("123.4")
Hello
Firmware is working but endocer is not setin any position and i dont know why is my loop implementation wron since i dont see log output from it ?
sensor:
- platform: template
id: x
lambda: !lambda |-
return float(id(variable_temp));
output:
- platform: gpio
pin: 12
id: gpio_d1
- platform: gpio
pin: 13
id: gpio_d2
# Example single-point configuration entry (for heating only)
climate:
- platform: thermostat
name: "Thermostat Climate Controller"
id: temperature_sensor
sensor: x
default_target_temperature_low: 20 °C
min_heating_off_time: 300s
min_heating_run_time: 300s
min_idle_time: 30s
visual:
min_temperature: 0.5 °C
max_temperature: 30 °C
temperature_step: 0.5 °C
heat_action:
- repeat:
count: 60
then:
- output.turn_on: gpio_d2
- delay: 30ms
- output.turn_on: gpio_d1
- delay: 30ms
- repeat:
count: !lambda |-
return id(temperature_sensor).target_temperature - 4.5;
then:
- logger.log: "Idle"
- output.turn_on: gpio_d1
- delay: 30ms
- output.turn_on: gpio_d2
- delay: 30ms
idle_action:
- logger.log: "Idle"
on_state:
- logger.log:
format: "The temperature set value %.1f virtual senzor %.1f global"
args: [ 'id(temperature_sensor).target_temperature', 'id(x).state']
- globals.set:
id: variable_temp
value: !lambda 'return id(temperature_sensor).target_temperature;'
also i still dont know how to utilize z (count) value as in my previouse sketch since it neeed to be count per loop
EDIT:
I think i will need to alter it to have something as this but i am unable to compile then since there ate 2 acitons any advice ?
EDIT:
Wouldent be better to use
output:
- platform: esp8266_pwm
id: pwm_output
instead of set level ?
Your last code example makes things unnecessary complex. Why do you want to work with modulo instead of simply switching on, waiting, switching off, waiting and repeating? Do you actually understand your original (= old) code or was it just a copy paste action? You need to understand what you do.
If nothing happens in your logs it might be simply because your actions don’t trigger. I am not really familiar with the climate and thermostat components. But it is possible that heat_action
is only triggered once when the system goes from cooling to heating? Maybe you have to use climate.on_state
instead. From the docs:
This trigger is activated each time the state of the climate device is updated (for example, if the current temperature measurement or the mode set by the users changes).
Hello yes I understand my original code, i write it ages ago, i am using digital write and seting certain value so in the end i am basically trying to generate the valve pattern similar what is done by encoder. But it starts to be really messy for me to write code in yamlI will try to move thinks to On_state but it seems to me that no signal is actually outputed out of board unfortunately I don’t have oscilloscope anymore. I tried original code you suggest on/off but it did not work so i am starting to try everything reasonable/not reasonable
Why don’t you start small and easy, with a climate and thermostat component that only contains logging commands in their heat_action
and in their on_state
blocks. This way you can test when which action is triggered. You can find out which action happens whenever you change the target temperature. That is the one you want to use for simulating your rotary encoder.
From there you slowly build up. Keep the logging actions and gradually add more commands to it.
This may be late, or silly, but have you considered just (mechanically) connecting a servo or stepper motor to the rotary encoder you wish to operate, and then just coding to have the servo rotate to the specific positions needed to operate the rotary knob?
I already have this part working only think what is not working is generation of signal wave other thinks in code are working, i even mange to move encoder, bit other problem rised, now o have problem if i repeat 30 time i one direction ant 30 times in other only first repeat is ever working, like if i upload onli one repeat for example to up direction encoder is moved correctly 30 pints up, if i upload only other direction it is moved 30 times down as expected, but if i try to null it 30 times down direction and then 30 times up it only goes 30 time down for some reason. I till think that i mess up timing shomehow in esp home i am really struggling to understand loop you suggested sinc you are doing 30 repeat instead of 50 and doing full signal wave instead only one site perchange
Yes, but this is legacy HW which vás already working this way in my previous setup also i want to left heater valve intact, only adding WI-FI capabiliz
Maybe add one full second delay between all down cycles and all up cycles. Your hardware might be picky about very quick changes on rotary direction.
Also check your YAML indentation. It looks broken to me. Add logging between each command so you can be sure they are all executed.
I do half of the original cycles because I switch on AND off in one cycle while your original loop switches on in one cycle and off in the next (through modulo calculation). This is exactly what I meant: You don’t understand your original code. Without understanding you won’t be successful.
One seond delay addet → no change
Indentation checked → by 2 people other than me → correct
this is not nesesearry true since you are not dooing half of cicle since:
- Full circle is one wave so pin one on , pin tow on, pin one off, pin two off this is one full circle this is what you are doing right
- I was dooing half of that an by Z i was counting if pin should on and off.
- i really dont see what i am not understanding maybe there is some language barier, i am not native speeker so may be a am writin somethin whitch mean something els if you know what i mean
also if i try to add log to inside of repeat under then ESP stop responding i need to remove it and flash it over ota again to start comunicating!
Actual version of code:
sensor:
- platform: template
id: x
lambda: !lambda |-
return float(id(variable_temp));
output:
- platform: gpio
pin: 12
id: gpio_d1
- platform: gpio
pin: 13
id: gpio_d2
# Example single-point configuration entry (for heating only)
climate:
- platform: thermostat
name: "Thermostat Climate Controller"
id: temperature_sensor
sensor: x
default_target_temperature_low: 20 °C
min_heating_off_time: 300s
min_heating_run_time: 300s
min_idle_time: 30s
visual:
min_temperature: 0.5 °C
max_temperature: 30 °C
temperature_step: 0.5 °C
heat_action:
- logger.log: "Idle"
idle_action:
- logger.log: "Idle"
on_state:
- logger.log:
format: "The temperature set value %.1f virtual senzor %.1f global"
args: [ 'id(temperature_sensor).target_temperature', 'id(x).state']
- globals.set:
id: variable_temp
value: !lambda 'return id(temperature_sensor).target_temperature;'
- repeat:
count: 30
then:
- logger.log: "loop"
#- output.turn_on: gpio_d1
#- delay: 30ms
#- output.turn_on: gpio_d2
#- delay: 30ms
#- output.turn_off: gpio_d1
#- delay: 30ms
#- output.turn_off: gpio_d2
#- delay: 30ms
- logger.log: "null"
- delay: 1s
- repeat:
count: 26
then:
#- output.turn_off: gpio_d2
#- delay: 30ms
#- output.turn_off: gpio_d1
#- delay: 30ms
#- output.turn_on: gpio_d2
#- delay: 30ms
#- output.turn_on: gpio_d1
#- delay: 30ms
- logger.log:
format: "set %.1f "
args: [ 'id(x).state']
- delay: 1s
Ok, let’s go through that step by step:
Your OLD code:
int z = 0;
// Set temperature to OFF
for (uint8_t i = 0; i < 60; ++i)
{
digitalWrite(ROTARY_ENC_PIN_2, z);
delay(30);
digitalWrite(ROTARY_ENC_PIN_1, z);
delay(30);
z = (z + 1) % 2;
}
My NEW sketch:
- repeat:
count: 30
then:
- output.turn_on: gpio_d2
- delay: 30ms
- output.turn_on: gpio_d1
- delay: 30ms
- output.turn_off: gpio_d2
- delay: 30ms
- output.turn_off: gpio_d1
- delay: 30ms
OLD output:
Pin2: 0–1–
Pin1: –0–1 ... and repeats this 30 times
NEW output:
Pin2: 1–0–
Pin1: –1–0 ... and repeats this 30 times
So YES, there is a difference. But only in polarity.
Is it possible, that your encoder needs inverted signals on its inputs???
If so you can either set the GPIOs to inverted or you can swap the turn_on / turn_off commands in my example.
I am sorry to say but this is starting to consume way to much of my time. You have to find out these things for yourself. Sorry again.
I understand and thank zou for your time :]
what you writen was what i trzed to explayn i already triet to switch polarity. But problem is still the sma onlz first ever repeat section work!
I think there is indead language barier
I think ESP home is not really easy for those custome stuffs
Thanky for your help!
maybe someone else can sugest something
After going through your old code, this shouldn’t be too complicated.
Could you please tell how you wired the valves, so I can reproduce it? (preferably even a schematic or photo) Did you used any resistors or transistor?
Thanks