flod-1 / LoxBerry-Plugin-Tibber2MQTT

LoxBerry Plugin Tibber2MQTT
3 stars 1 forks source link

Level Status as Integer Value #2

Closed TheBruny closed 1 year ago

TheBruny commented 1 year ago

Dear flod-1,

Loxone does have trouble with reading an UDP input as STRING. It is possible (from my knowledge) to read just the first Sign of the String and use it in a Status Block, but VERY_CHEAP and VERY_EXPENSIVE do have same first char.

Therefore I would like to request the following update in process.php

 if(($tb_config->SendasCents == true) && ($requestedValueKey != "level")){
                                                $priceRecord[$requestedValueKey] = $priceRecord[$requestedValueKey]*100;
                                        }
                                        if($requestedValueKey == "level"){
                                                switch ($priceRecord[$requestedValueKey]){
                                                        case "NORMAL":
                                                                $priceRecord[$requestedValueKey]=0;
                                                        break;
                                                        case "CHEAP":
                                                                $priceRecord[$requestedValueKey]=-1;
                                                        break;
                                                        case "VERY_CHEAP":
                                                                $priceRecord[$requestedValueKey]=-2;
                                                        break;
                                                        case "EXPENSIVE":
                                                                $priceRecord[$requestedValueKey]=1;
                                                        break;
                                                        case "VERY_EXPENSIVE":
                                                                $priceRecord[$requestedValueKey]=2;
                                                        break;
                                                        default:
                                                                $priceRecord[$requestedValueKey]=9;// ERROR
                                                }
                                        }

Reference around Line 209

https://developer.tibber.com/docs/reference#pricelevel

With best regards TheBruny

flod-1 commented 1 year ago

Thanks for your report, @TheBruny! Problem is fixed in new version. :)