Heating and window contact - a (simple?) rule [SOLVED]

Your variable thermoValveName is just a string. It happens to look like one your Item’s names, but is just string, same as “banana”. So it doesn’t have a .sendCommand method, it’s not an actual Item.

You are in luck though, the sendCommand() action actually wants to be given an Item name as a string, and will search for it for you.
Beware, the command must be a string too.

sendCommand(thermoValveName, setValue.toString)

For more advanced get-an-Item-from-string-name methods, see

The general approach you are using is covered here

which includes more than one approach to grabbing an Item by name