Then the Smarthome Designer isn’t happy about the result from now.getDayOfWeek is format int, and the other is Numberitem…
I can’t find a way to convert it so it’ll be happy? as far as i can read, the NumberItem can be int, float and so on…
I think it’s very hard to figure out how to manage all the datatypes which basically only is numbers… But i think often i delal with a lot of problems, where it says the number is BigDecimal and can’t convert to NumberItem - but i can’t see anywhere how to deal with this?
Basically it’s the same like the first problem, where it can’t convert int to NumberItem…
Hmm i understand, but can’t see why - also still problem:
In Items file
Number Heatpump_actual_day
In my Rule:
rule "Opdater aktuel dag"
when
Time is midnight
then
if (Heatpump_actual_day != now.getDayOfWeek)
{
var int weekint
weekint = now.getDayOfWeek
Heatpump_actual_day = weekint
}
The Designer wouldn’t accept the "Heatpump_actual_day = weekint " since it can’t convert from Int to Number
It’s Number, because it represents item type, and item types are defined somewhere (OH core, ESH core), the same way you can’t use, for example, MyInteger as type in C++ instead of int.
At the first glance, there are two problems in your rule:
You must use Item.state != Value instead of Item != Value (Heatpump_actual_day.state != now.getDayOfWeek)
You can’t assign value to an item. You must use sendCommand or postUpdate. In your case, you should use postUpdate(Heatpump_actual_day, weekint) or Heatpump_actual_day.postUpdate(weekint)
As far as I know, you have to use postUpdate/sendCommand. Maybe someone involved in ESH can explain it more thoroughly. I just saw that as an error, so I thought I should warn you about it. You don’t have to be sorry, we are all here to help each other.
You use sendCommand when you want to command something to change, like turning a light ON or setting a thermostat setpoint to a new numeric value. You use postUpdate when you want the state of an item to change to a new value, like the current weather conditions.
Bindings are typically doing postUpdates internally, and listening for commands to interpret and forward to the connected systems, but of course you can do either/both in your own custom rules or over the API.