Closed newbie22-guy closed 2 years ago
Your line (177) should be this "contrast: 0.4"
As for the others, I see your line numbers are different from my original code. Please post me your full code and I'll take a look. FYI - To format the code you post, start the block of text with:
and end it with:
Thanks for your response. The coding (from my initial query) I suspect was an old revision, as I re-downloaded the files today and compared them and noted some alterations. I have now used the latest available YAML.
Based on your reply I now have the original code (now line 196).
This initially gave an error requesting an indentation check, By revising to as below the indentation has been satisfied, but the colon is still posing an issue, I have attached the specific fault/ issue this highlights.
esphome:
name: thermostat_kitchen
platform: ESP8266
board: d1_mini
on_boot:
then:
- lambda: "id(oled_contrast).publish_state(0.4);"
- switch.turn_off: dallas_power
- delay: 25s
- switch.turn_on: dallas_power
substitutions:
room: Kitchen # Room Name
entity_heater: input_boolean.tut_thermo_fire_lr
entity_cooler: input_boolean.tut_thermo_cool_lr
default_low: "20.0"
default_hi: "28.0"
wifi:
ssid: "Deliberately Removed"
password: "Deliberately Removed"
logger:
logs:
climate: none
sensor: none
dallas.sensor: none
api:
ota:
i2c:
switch:
- platform: gpio
id: dallas_power
pin:
number: GPIO03
- platform: template
id: heat_cool
optimistic: true
- platform: gpio
id: relay_heater
pin: D0
inverted: true
- platform: gpio
id: relay_cooler
pin: D5
inverted: true
- platform: template
id: brightness
optimistic: true
binary_sensor:
- platform: template
id: fire
- platform: template
id: cool
- platform: gpio
id: button
pin:
number: D4
inverted: true
on_press:
then:
- switch.toggle: heat_cool
on_click:
- min_length: 1000ms
max_length: 20000ms
then:
- switch.toggle: brightness
dallas:
pin: D3
update_interval: 3s
climate:
- platform: thermostat
min_cooling_off_time: 0s
min_cooling_run_time: 0s
# min_fanning_off_time: 0s
# min_fanning_run_time: 0s
min_heating_off_time: 0s
min_heating_run_time: 0s
min_idle_time: 0s
visual:
min_temperature: 15 °C
max_temperature: 30 °C
name: "${room} Thermostat"
id: this_thermostat
sensor: internal_temperature
default_target_temperature_low: ${default_low}
default_target_temperature_high: ${default_hi}
cool_action:
- switch.turn_on: relay_cooler
- lambda: id(cool).publish_state(true);
- homeassistant.service:
service: homeassistant.turn_on
data:
entity_id: ${entity_cooler}
heat_action:
- switch.turn_on: relay_heater
- lambda: id(fire).publish_state(true);
- homeassistant.service:
service: homeassistant.turn_on
data:
entity_id: ${entity_heater}
idle_action:
- switch.turn_off: relay_cooler
- switch.turn_off: relay_heater
- lambda: id(cool).publish_state(false);
- lambda: id(fire).publish_state(false);
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: ${entity_cooler}
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: ${entity_heater}
sensor:
- platform: template
id: oled_contrast
- platform: dallas
id: internal_temperature
address: 0x28ff6401be7b6410
- platform: rotary_encoder
id: encoder
pin_a:
number: D6
mode: INPUT_PULLUP
pin_b:
number: D7
mode: INPUT_PULLUP
on_clockwise:
- if:
condition:
switch.is_on: brightness
then:
- sensor.template.publish:
id: oled_contrast
state: !lambda "return id(oled_contrast).state + 0.01;"
- lambda: |-
id(oled1).set_contrast( id(oled_contrast).state );
else:
- if:
condition:
switch.is_on: heat_cool
then:
- climate.control:
id: this_thermostat
target_temperature_high: !lambda "return id(this_thermostat).target_temperature_high + 0.5;"
else:
- climate.control:
id: this_thermostat
target_temperature_low: !lambda "return id(this_thermostat).target_temperature_low + 0.5;"
on_anticlockwise:
then:
- if:
condition:
switch.is_on: brightness
then:
- sensor.template.publish:
id: oled_contrast
state: !lambda "return id(oled_contrast).state - 0.01;"
- lambda: |-
id(oled1).set_contrast( id(oled_contrast).state);
else:
- if:
condition:
switch.is_on: heat_cool
then:
- climate.control:
id: this_thermostat
target_temperature_high: !lambda "return id(this_thermostat).target_temperature_high - 0.5;"
else:
- climate.control:
id: this_thermostat
target_temperature_low: !lambda "return id(this_thermostat).target_temperature_low - 0.5;"
display:
- platform: ssd1306_i2c
id: oled1
update_interval: 0.5s
"contrast: 0.4"
model: "SH1106 128x64"
rotation: 180
address: 0x3C
lambda: |-
if (id(fire).state) {id(ani_fire).next_frame(); it.image(0, 0, id(ani_fire));}
else if (id(cool).state) {id(ani_fan).next_frame(); it.image(0, 0, id(ani_fan));}
else {it.image(0, 0, id(home_thermometer));}
it.print(64, 0, id(font1), TextAlign::TOP_CENTER, "${room}");
it.printf(64, 4, id(font2), TextAlign::TOP_CENTER, " %.1f°", id(internal_temperature).state);
it.printf(0, 64, id(font3), TextAlign::BASELINE_LEFT, "L:%.1f°", id(this_thermostat).target_temperature_low);
it.printf(128, 64, id(font3), TextAlign::BASELINE_RIGHT, "H:%.1f°", id(this_thermostat).target_temperature_high);
if (id(brightness).state) {it.image(56, 51, id(bulb));}
else if (id(heat_cool).state) {it.image(56, 51, id(arrow_right));}
else {it.image(56, 51, id(arrow_left));}
animation:
- file: "_icons/thermostat/fan.gif"
id: ani_fan
- file: "_icons/thermostat/fire.gif"
id: ani_fire
image:
- file: "_icons/thermostat/home-thermometer.png"
id: home_thermometer
- file: "_icons/thermostat/arrow-left-circle-outline.png"
id: arrow_left
- file: "_icons/thermostat/arrow-right-circle-outline.png"
id: arrow_right
- file: "_icons/thermostat/lightbulb-on-outline.png"
id: bulb
font:
- file: "_fonts/nasalization.ttf"
id: font1
size: 12
- file: "_fonts/refsan.ttf"
id: font2
size: 42
- file: "_fonts/refsan.ttf"
id: font3
size: 13```
If I now remove line 196 from the code, the following lines show faults. 82 #min_cooling_off_time: 0s 83 #min_cooling_run_time: 0s 86 #min_heating_off_time: 0s 87 #min_heating_run_time: 0s 88 #min_idle_time: 0s
With the addition of the # at the beginning of these the line issue is resolved, and I can successfully install the code.
Unfortunately as previously while the setpoints display and alter, the temperature is not displayed on the OLED or homeassistant
LOL, When I quoted "contrast: 0.4" - I assumed you knew the quote-marks were not part of it. 😜
I've used you code (as is) in a new device here and there's no such errors. My conclusion is you're not running the latest version of ESPHome.
- Always update my shared code examples because of the 'Breaking Changes' that are made from time-to-time.
Haha yes that's my mistake, I did realise the error of my ways prior to trying the install.
You were correct in relation to the ESPHome, I have just updated that, and am currently retrying an install of the YAML as per the download file.
I'd like to thank you very much for your assistance 👍
I'll keep you posted but hopefully that will resolve the issues for me
No worries fella. I'm glad we got it 'sorted' 👍
Enjoy. I'm always about if ya need more help.
Well some very encouraging progress there, the install went through no trouble. I have the dimming function available now in addition to the setpoint adjustment etc.
I still haven't got temperature display on the OLED or homeassistant though.
Coolio....
As for the display, comment out this line then check the logs to see if the Dallas readings are being shown...
I have done that and run the logs The error message reads as follows ][W][dallas.sensor:127]: 'internal_temperature' - Scratch pad checksum invalid!
I haven't seen that error before... A Googling found this thou: https://github.com/esphome/issues/issues/903
I've tried to follow the suggestion as per above.
I've spent quite some time this morning trying to resolve the issue, unfortunately to no avail.
I've tried a number of different chargers, and cables. Carried out resistance checks to eliminate the possibility of a bad solder joint. I've swapped the D1 mini 4 times. Changed out the ds18b203 times. I've even soldered the ds18b20 & resistor directly to the D1, to count out the possibility of bad connections etc
Unfortunately they symptoms of my issue remain, and I must confess I am now at a dead loss?!?!?
Try this, Wire the Dallas sensor, on its's own to a D1 Mini and flash only with the example(s) here https://esphome.io/components/sensor/dallas.html
If it still doesn't work, I guess it's your sensors.
I was beginning to suspect likewise, but I was dubious that I would have so many faulty sensors.
Initially I built the DS_Fake_Tester by electrical-pro (https://github.com/electrical-pro/Ds_Fake_Tester) This proved to be quite encouraging as all the sensors indicated as being genuine, and displayed readings.
I've had another play with these this morning. Using the guide below https://everythingsmarthome.co.uk/howto/building-a-temperature-sensors-for-home-assistant-wemos-d1-mini-with-ds18b20-build-guide/
Initially I built this up on breadboard for simplicity of substituting sensors & D1's. I have successfully managed to gain temperature readings from multiple sensors. I have also managed this with a number of D1 mini's.
I amended the code from the example to increase the refresh rate to 3 sec, and alternated the GPIO pin between pin 3 & 4 (to confirm no issue with either pin) Both worked as expected and provided updates every 3 secs, with no issue over the period of 15mins.
I have since remounted the D1 mini back to the PCB (I've used pin sockets for ease) Reverting the GPIO for the Dallas to GPIO3, as this conforms to the PCB track layout. Via jumper wires to the ds18b20 solder pads, the temperature readings operate as expected. Obviously the OLED and the Rotary encoder are out of the loop at this point. With the ds18b20 legs placed through the relevant solder pads, running the above code the setup has run for about 1 hour now faultlessly
I wish you would have said from the outset.... the Dallas Sensor 'Label' is reversed on those! You have to mount it on the underside.
Ah sorry my bad, I should have been more accurate in my explanation.
I had noticed that and that is why the photo only shows the ds18B20 legs visible at the solder pads. (They are just sat in place at the moment)
This setup using this mornings code operates (minus display etc).
If I again revert to the original code the same scenario persists of no temp display on the OLED or home assistant.
The purpose (in my mind) of this test was to confirm that the data pin GPIO3 was able to receive the signal via the PCB. In the thought of a bad contact, high resistance on x1 line etc
This seems to have proven the board healthy, and the ds18b20's are good too.
I'm not now sure where this is pointing?!?
Can I ask what supply you use for your examples? As previously mentioned I have tried a few USB supplies, and now wonder if they aren't able to supply the required current for both the D1 & the OLED, although this wouldn't explain the non operation if the OLED is disconnected.
Ah so, you have the Dallas sensor wired correct, after-all. Hmmmm.... That's even weirder !
PSU wise, I've run these boards, without issue, on everything from a USB port on my PC to various 'Phone Chargers' and Multi-sockets with USB charger sockets.
What value do you have in R1, I can't tell from the Photo colours if it's 4.7K (Red) or 47K (Orange) - Either way, that's really only needed if the Dallas Sensor is on long leads. I guess we could try removing it completely, to see if that fixes it.
Hmmm yeah that is making things more complicated.
I have tried the PC USB also, and a number of phone chargers.
R1 is 4.7K 0.25W 1% (Yllw, Violet, Red + Brown band)
I'm actually a step ahead of you with removing the resistor, although I only de-soldered 1 leg and lifted it clear, it should effectively achieve the same end.
Software wise, we've sorted that Component wise, all's been verified PSU, shouldn't have been an issue anyway - (still was worth the check thou - You never know)
... and you've previously stated you've checked for shorts, bad connections, etc.
There's nothing else to check... We've covered everything I would have done in the same situation.
:(
Ha yeah that's where I've ended up too.
I'll try another full component assembly this evening, purely on breadboard as it makes it quicker & easier to switch components etc
It's really confusing the hell outta me
Well I have had some success at last 😁
I tried rebuilding the circuit on breadboard this evening, with no joy, exactly the same results as previously.
In a final vain attempt I put the D1 back on the PCB, and after a couple of reboots it fired into life.
Fully functioning local OLED & home assistant indication. Graphics alter if temp varied to setpoints, the works.
I am completely bamboozled as to how this came about, but more than a little chuffed at the same time lol
Just thought I would offer an update, and say thanks again for your assistance, it's massively appreciated
That's great News!... and Phew 👍
YAY you - Coz, I'd totally ran out of ideas of what to check.
Thanks for letting me know - If you do find out what it was, please do let me know.
I have encountered an issue when trying to compile this project and hope you can assist.
When I used the code supplied I get the following error messages
The first issue (lines 72, 73, 76, 77 &78 I resolved with the addition of a # as seen in lines 74 & 75.
The error for line 177 [set_contrast] has been significantly more difficult, and I have not been able to resolve this. If I move the indentation in or out by x1 column the indentation error does not repeat but the colon then becomes an issue as the YAML sees it as a mapping value.
I have managed to temporarily bypass this issue, with the deletion of the set_contrast: line (and the associated lines in the YAML). This allowed me to achieve an upload and some degree of success with the thermostat.
Upon upload I have input the Dallas sensor address, and uncommoned the specified lines as per YouTube tutorial
Within homeassistant I have functionality of both setpoints via the rotary encoder. This is mirrored on the OLED display, with the graphics.
Unfortunately I have no temperature indication either on the OLED or on homeassistant.