Toggling a servo for a generic thermostat

Hi all,

This is my first home assistant project, so apologies if I’m asking rather basic questions.

My aim is to control an existing thermostat using a servo motor, but I’m running into problems linking the generic thermostat with something that isn’t a switch.

So far I’ve set up a generic thermostat, and have successfully linked it with an AM3202 connected to a NodeMCU v3. I’ve also connected a servo motor to the NodeMCU, and configured it as a shutter. I can open and close this from home assistant no problem:

I’ve then set the generic thermostat up like this:

climate:
  - platform: generic_thermostat
    name: Dining Room Thermostat
    heater: cover.tasmota
    target_sensor: sensor.tasmota_am2301_temperature
    min_temp: 10
    max_temp: 30
    target_temp: 20
    cold_tolerance: 0.3
    initial_hvac_mode: "off"
    away_temp: 16
    precision: 0.1

which successfully links with the temperature.

However, it is stuck in ‘Idle’ mode, and I don’t think it’s working with the cover.tasmota.

I’ve been trying to look into creating a switch template, which appears as a switch to the generic thermostat, and controls the servo motor as a cover device behind the scenes. However, I’ve got stuck at trying to save the state of the servo, as all it returns over MQTT is ‘Unknown’. I’m not expecting it to be powered off very often, so a solution where it always initialises as ‘off’ would be fine.

I started looking at Template Switch - Home Assistant and got a bit lost, so I thought I’d come here to see if anyone had any more advice/guidance?

All thoughts/comments appreciated!

Thanks!
Jonathan

To start you should look at the entity cover.tasmota,like you said its a cover entity.
From that you can go to services in the Developers Tools, when you type in cover it will show all the actions for that. Like:

service: cover.open_cover
service: cover.close_cover

Or any other way you want to adjust it. Apply that to the template:

switch:
  - platform: template
    switches:
      thermostatservo:
        turn_on:
          service: cover.open_cover
          target:
            entity_id: cover.tasmota
        turn_off:
          service: cover.close_cover
          target:
            entity_id: cover.tasmota

Hi
How does the servo motor supposed to work? What type of heating? Sounds very interesting. Put up a picture of the setup so far.

Perfect thank you so much! Turns out I was on the right lines - I just needed that one extra step!

I’m in the process of doing the CAD for the 3D print to mount it next to the existing thermostat. Rationale is I’m not allowed to fiddle with the existing one, so making an overly complicated system to turn the dial for me is the only option (but quite an interesting one).

I see what you’re doing. If the servo has to fit over the existing thermostat you could reduce the size by using an ESP01(tiny in comparison) to control the servo and have the Bigger nodemcu with temp sensor separate but via HA still controlling the servo. In my setup I have removed the Thermostat from the wall and put a sonoff mini in the hole connected to the old wires and all covered by a blanking plate. Then I have a temperature sensor setup elsewhere.

I’ll probably end up getting some smaller controllers, and may well swap this one out as you suggest - it’s just one I have lying around with plenty of ports for prototyping with. Having a temperature sensor with it is useful anyway, and combining them into one means only one battery is needed. Connecting straight to the wires would be a lot simpler!

If you are considering using battery then will have to pick mcu carefully. You’ll have to use deep sleep most of the time. You’ll have to decide on built in charger and battery monitoring, which add to battery drain. Flat battery with no-one home and heating stuck on full blast. Toasty and expensive.
You sure we can’t tempt you to rip out old thermostat and run replacement from old devices power? :smiling_imp: who would know? It could all be replaced in minutes.

I’m using a power bank and so far that’s lasted over a day and is still >75%, so I don’t think I’ll have to recharge that often. There is a socket on the other side of the room, so I may well end up running a long usb cable over the door to it cause as you say getting the heating stuck on is a risk. I’ll probably end up having the unit with the servo powered by cable, and the thermometer units in each room by battery, as it’s less critical if they run out.

Unfortunately the landlord would probably evict me on the spot it I started fiddling with the old one, otherwise yes that would be ideal. He can’t have a problem with me using a servo to turn the dial though, as that’s what the dial’s for!