Page 1 of 1

Update van "Text" device fails

Posted: Wednesday 11 September 2024 14:56
by hvanschaick
I create a "Text" device in a python plugin
Like this:
Domoticz.Device(Name="lowestPriceToday", Unit=3, TypeName="Text",Options=7).Create()

and attempt to update like this:
Devices[3].Update(nValue=price, sValue="{:.2f} €".format(price))
where price is a float.

I get this error:
2024-09-11 14:52:11.172 Error: Next Energy: (CDevice_update) Next Energy - lowestPriceToday: Failed to parse parameters: 'nValue', 'sValue', 'Image', 'SignalLevel', 'BatteryLevel', 'Options', 'TimedOut', 'Name', 'TypeName', 'Type', 'Subtype', 'Switchtype', 'Used', 'Description', 'Color' or 'SuppressTriggers' expected.
2024-09-11 14:52:11.172 Error: Next Energy: Call to function 'CDevice_update' failed, exception details:
2024-09-11 14:52:11.172 Error: Next Energy: (CDevice_update) Next Energy - lowestPriceToday: Failed to parse parameters: 'nValue', 'sValue', 'Image', 'SignalLevel', 'BatteryLevel', 'Options', 'TimedOut', 'Name', 'TypeName', 'Type', 'Subtype', 'Switchtype', 'Used', 'Description', 'Color' or 'SuppressTriggers' expected.
2024-09-11 14:52:11.172 Error: Next Energy: Call to function 'CDevice_update' failed, exception details:
2024-09-11 14:52:11.173 Error: Next Energy: Exception: 'TypeError'. No traceback available.

Any suggestions?
This is running on Raspian Buster, with Domoticz 2024.7

Re: Update van "Text" device fails

Posted: Wednesday 11 September 2024 15:37
by waltervl
Python plugin framework normally follows the API method for updating devices.
So for a text sensor see wiki page https://www.domoticz.com/wiki/Domoticz_ ... ext_sensor
nvalue=0
svalue=TEXT = Text you want to display

In your case nvalue=price will not be nvalue=0 so could give an error.

Re: Update van "Text" device fails

Posted: Wednesday 11 September 2024 17:55
by hvanschaick
Thanks for the reply. But the device with index 2 gives the same error where there is an sValue and the nValue = 0

This update for a similar items fails the same way:

Devices[2].Update(nValue=0, sValue=hours_lowest[0])
and was created as:
Domoticz.Device(Name="lowestEnergyTOD", Unit=2, TypeName="Text",Options=7).Create()

Re: Update van "Text" device fails

Posted: Wednesday 11 September 2024 19:27
by willemd
Just thinking out loud....

The errormessage indicates a type error of the passed parameters, but your are passing a 0 and you are passing a string (although some strange € characters in the string, but when I try it in a normal python program it does not trigger an error), so you don't seem to be doing anything wrong.

To me it is not clear what the "options=7" means during device creation. I can't find a clear explanation of that in the wiki.
Is it necessary to use it for a text device? What if you try without? Could it have to do with the error?
I normally would used Type=243, Subtype=19 without any options parameter.

And what if you try with a simpler string, like just sValue="abc"? Same error?

Re: Update van "Text" device fails

Posted: Thursday 12 September 2024 9:16
by hvanschaick
Yes, when I put "Unknown" as string, the same result.
I saw this Options=7 in some other plugin, without it, creation fails... Indeed I have not clue what is....
Trial and Error...
I could try defining it with Type, subtype instead op the "Text" parameter...

Re: Update van "Text" device fails

Posted: Thursday 12 September 2024 10:07
by willemd
hvanschaick wrote: Thursday 12 September 2024 9:16 Yes, when I put "Unknown" as string, the same result.
I saw this Options=7 in some other plugin, without it, creation fails... Indeed I have not clue what is....
Trial and Error...
I could try defining it with Type, subtype instead op the "Text" parameter...
also try adding "used=1" (default seems to be 0=not used)

Re: Update van "Text" device fails

Posted: Thursday 12 September 2024 10:18
by hvanschaick
Ok, fixed. My Bad. The string was not a proper string... :oops:

Re: Update van "Text" device fails

Posted: Thursday 12 September 2024 10:56
by willemd
hvanschaick wrote: Thursday 12 September 2024 10:18 Ok, fixed. My Bad. The string was not a proper string... :oops:
So how come it also failed when you used "Unknown" as string?