I use a selector to input the desired temperature.
I have a temperature sensor connected to a ESP8266 that gives the temperature in the room.
I want to compare both to decide if the heater must switch on or off.
Can I covert a number to a string and/or can I convert a string to a number in Blocky?
Looking forward to a solution.
=======================================================================================================
The error code is:
2017-10-16 22:36:04.885 Error: EventSystem: Lua script error (Blockly), Name: Thermostaat_3 => [string "result = 0; weekday = os.date('*t')['wday']; ..."]:1: attempt to compare string with number
My Blocky is:
My Selector is:
String versus Number in Blocky
Moderator: leecollings
-
- Posts: 80
- Joined: Sunday 29 November 2015 14:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Location: Halle, the Netherlands
- Contact:
-
- Posts: 3
- Joined: Sunday 15 October 2017 14:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: String versus Number in Blocky
You are comparing a temperature with "OFF". I don't think you can do that. But if that is valid then your report may be a duplicate of the issue I reported at http://www.domoticz.com/forum/viewtopic ... 8e58c96f92
I suggest you log the values you're comparing as I did in my Blocky code - then you can see what is going on.
The log will also show you which IF statement you're failing on.
I would be very interested in your findings.
I suggest you log the values you're comparing as I did in my Blocky code - then you can see what is going on.
The log will also show you which IF statement you're failing on.
I would be very interested in your findings.
-
- Posts: 80
- Joined: Sunday 29 November 2015 14:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Location: Halle, the Netherlands
- Contact:
Re: String versus Number in Blocky
Thanks psb777 for your reply.
I use a selector switch in Domoticz because I want to input a desired temperature. The first level in a selctor switch is always ‘Off’. I can hide that level, so you don’t see it in your dashboard, but still the levels are strings.
The measured value is a number.
In lua you can convert a string to a number with the statement ‘tonumber’.
How do I compare in Blocky a selector switch value with a measured number value?
I had a solution, see Blocky example, but that is in my opinion a lazy programmers solution. In this case it can be ok, but in other situations I want a small solution.
Who can help me?
I use a selector switch in Domoticz because I want to input a desired temperature. The first level in a selctor switch is always ‘Off’. I can hide that level, so you don’t see it in your dashboard, but still the levels are strings.
The measured value is a number.
In lua you can convert a string to a number with the statement ‘tonumber’.
How do I compare in Blocky a selector switch value with a measured number value?
I had a solution, see Blocky example, but that is in my opinion a lazy programmers solution. In this case it can be ok, but in other situations I want a small solution.
Who can help me?
Who is online
Users browsing this forum: No registered users and 1 guest