Total Beginner Question: How to control a ZWAVE relay through the HAB panel?

I am trying to write a simple widget to control a relay based on a temperature reading provided by an Aotec multisensor 6 and a user specified temperature. I haven’t been able to find a single Angular JS example of a simple custom widget to control a relay, so I was wondering if anyone could provide me with one or offer me some guidance.

Thanks!

It’s not Angular JS that controls the relay it’s OH through the binding for the relay
All you need is a simple switch widget linked to your relay item.

Hi Robert

This will display temp for you in HabPanel. This assume that you have created an ITEM definition for your Aeotec Temp Channel on your sensor. And, its called ‘FibaroEye1Temp’ so just change that to reflect your Temp channel and away you go. It will display in Celcius as shown with the &#176C. If you post your items config file I can tell you exactly what you’d need.

	<div class="bigDash">
		<div class="description">Living Room</div>    
		<div class="top">
			<div class="icon on"><svg viewBox="0 0 48 48"><use xlink:href="/static/matrix-theme/squidink.svg#thermometer-3"></use></svg></div>
			<div class="value">
				<div class="main">{{itemValue('FibaroEye1Temp') | number:1}}</div>
				<div class="sub">&#176C</div>
			</div>
		</div>

Regards

All you need is a simple switch widget linked to your relay item.

So I’ve figured out how to do that, but now Im trying to write a script into a custom widget that will switch the relay on or off automatically depending on the temperature. Is this something that I could do with Habpanel?

No, you need to write a rule for that:

Can the rule reference a value set in the habpanel? So If I only wanted the switch to turn on at a temperature specified by text or slider input for example

No, the rule can reference a value set to an item
Habpanel widget are linked to Item and you can change their values in that UI, or Claussic UI or via the rEST API or via rules.

In the rules, you (generaly ) use item states to trigger the rules and the state values to achieve what you want to do

rule "Temperature"
when
    Item Temperature changed
then
    if (Temperature.state as Number < 18) {
        Heating.sendCommand(ON)
    }
end

So, how can you really automate anything? Like do I have to hard code a new rule or change the code every time I want to change the time my lights turn on (for example)? It seems like I should be able to do stuff like this through the ui (Im probably missing something big here)

You can, you just need more items

Number HeatingSetpoint
rule "Temperature"
when
    Item Temperature changed
then
    if (Temperature.state as Number < HeatingSetpoint as Number) {
        Heating.sendCommand(ON)
    }
end

And you can put a slider widget in HABpanel linked to HeatingSetpoint

You can use the Caldav binding to schedule events

By thinking long and hard about what you want to automate and why and how. It’s not easy but in my opinion a good home automation system shouldn’t even have a UI. It should just work. The house should do the work for you, not the other way around. So coding fail safe rules and redundant hardware are important.
I have not touched my heating settings for two years now and I have individually controlled room heating. I thought about the house modes (Away, School days, weeks ends, holidays, sickness…) I Though about the st points for the different rooms. I though about the different schedules for different rooms ) I though about integrating presence in the system. And after a LOT of thinking and planning and coding , I just works…

Thank you so much for your replies, this should be enough to get me started. Didnt realize I could make my own items outside of those strictly associated with hardware, have a lot to learn

Yes indeed, we all had to. Read the docs again and again.
Write down the examples, don’t just copy and paste, this way you’ll get used to the syntax.
Read the docs again.
Read the binding docs
Search the forum. Someone has probably asked the same question before.

Welcome and good luck