Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eve show negative values for temperature (internet speed) in history #85

Open
Kienz opened this issue Apr 15, 2020 · 15 comments
Open

Eve show negative values for temperature (internet speed) in history #85

Kienz opened this issue Apr 15, 2020 · 15 comments

Comments

@Kienz
Copy link

Kienz commented Apr 15, 2020

I want to log the internet speeds in fakegato-history in Mbps. In the fakegato-history json file the values look good.
Plugin:
https://github.com/Kienz/homebridge-speedtest-net

persistent json:
{"firstEntry":0,"lastEntry":2,"usedMemory":2,"refTime":608625820.9330001,"initialTime":1586933020.933,"history":["noValue",{"time":1586933020.933,"setRefTime":1},{"time":1586933020.933,"temp":422.75,"humidity":17.97,"pressure":55}]}

temp = download speed
humidity = upload speed
pressure = ping in ms

homebridge log:
4/15/2020, 8:43:40 AM] [Internet] Download: 422.75 Mbps
[4/15/2020, 8:43:40 AM] [Internet] Upload: 17.97 Mbps
[4/15/2020, 8:43:40 AM] [Internet] Ping: 55 ms
[4/15/2020, 8:43:40 AM] [Internet] External IP: 149.172.218.226
[4/15/2020, 8:43:40 AM] [Internet] Add history data 422.75 17.97 55
[4/15/2020, 8:43:40 AM] [Internet] First entry Internet: 0
[4/15/2020, 8:43:40 AM] [Internet] Last entry Internet: 2
[4/15/2020, 8:43:40 AM] [Internet] Used memory Internet: 2
[4/15/2020, 8:43:40 AM] [Internet] 116 Internet: 00000000000000009ce4462403 0102 0202 03020300c00f00000000000000000101
[4/15/2020, 8:43:40 AM] [Internet] ** Fakegato-storage write FS file: /homebridge/accessories/homebridge-4_Internet_persist.json "firstEntry":0,"lastEntry":2,"usedMemory":2,"refTime":608625820.9330001,"initial
[4/15/2020, 8:44:28 AM] [Internet] Data request Internet: 01140100000000
[4/15/2020, 8:44:28 AM] [Internet] Address requested Internet: 1
[4/15/2020, 8:44:28 AM] [Internet] Internet Entry: 2, Address: 2
[4/15/2020, 8:44:28 AM] [Internet] Data Internet: 1501000000 0100 0000 819ce446240000 0000 00 0000 10 02000000000000000723a505072602

Eve shows for this entry the value "-232,6" (in celcius). What is wrong?
I'm using the temperature service and the "weather" fakegato-history.

@simont77
Copy link
Owner

CurrentTemperature is by default limited to 0-100°C in Homekit. Maybe this is the reason of the strange behavior. You could try to change the MaxValue property of the Temperature characteristics in your Accessory. It is also possible that Eve simply misunderstand values outside the usual range.

@tobekas
Copy link

tobekas commented Apr 18, 2020

The entry for temperature in Eve‘s history protocol is 2 byte with 2 decimals, so it technically can hold values in the range of -327,68...327,67. Your value is too high, so there will be an overflow.
This might be different for the actual temperature value (default Homekit value), since this data type is FLOAT als min/max value properties can be adjusted. But for history values you have this restriction.

@ebaauw
Copy link
Contributor

ebaauw commented Apr 18, 2020

I wouldn't try and go below -273.15, though.

@Kienz
Copy link
Author

Kienz commented Apr 18, 2020

I got values from +381.7 to -385.7 🧐

@jhubig
Copy link

jhubig commented Nov 21, 2020

Hello,

I have changed the characteristic of CurrentTemperature in \usr\local\lib\node_modules\homebridge\node_modules\hap-nodejs\dist\lib\gen\HomeKit.js file.

image

Now I can see negative values displayed in HomeKit (e.g. in iOS Eve App). But in the fakegato history file I can still see null for the temperature values which leads to measurement entries in Eve App shown with 0.0. Something else I need to change? Thanks for your help.

{"temp":null,"humidity":93.9,"ppm":0,"time":1605996070}

image

@NorthernMan54
Copy link
Collaborator

What does your addentry look like? The null value suggests that temperature is not being passed.

@jhubig
Copy link

jhubig commented Nov 22, 2020

I'm using the homebridge-cmd4 plugin which adds the data to fakegato history. Here the part where the values are added:

firstParm       = this.fakegatoConfig['temp']       || '0';
               secondParm      = this.fakegatoConfig['humidity']   || '0';
               thirdParm       = this.fakegatoConfig['ppm']        || '0';
               ucFirstParm     = ucFirst(firstParm)       || '0';
               ucSecondParm    = ucFirst(secondParm)      || '0';
               ucThirdParm     = ucFirst(thirdParm)       || '0';

               firstParmIndex = CMD4_ACC_TYPE_ENUM.properties.indexOfEnum(i => i.type === ucFirstParm);
               secondParmIndex = CMD4_ACC_TYPE_ENUM.properties.indexOfEnum(i => i.type === ucSecondParm);
               thirdParmIndex = CMD4_ACC_TYPE_ENUM.properties.indexOfEnum(i => i.type === ucThirdParm);


               firstParmValue = (this.testStoredValueForIndex(firstParmIndex) < 0) ?
                  firstParmValue : this.getStoredValueForIndex(firstParmIndex);
               secondParmValue = (this.testStoredValueForIndex(secondParmIndex) < 0) ?
                  secondParmValue : this.getStoredValueForIndex(secondParmIndex);
               thirdParmValue = (this.testStoredValueForIndex(thirdParmIndex) < 0) ?
                  thirdParmValue : this.getStoredValueForIndex(thirdParmIndex);


               this.log.debug("Logging temp:%s humidity:%s ppm:%s", firstParmValue, secondParmValue, thirdParmValue);
               // Eve Room (TempSensor, HumiditySensor and AirQuality Services)
               this.loggingService.addEntry({time: moment().unix(),
                  temp:firstParmValue,
                  humidity:secondParmValue,
                  ppm:thirdParmValue});
               break;
            }

But logging is generally working. Just not the negative values. We have to be fast. I don't know how long we have these weather conditions 😃

image

@simont77
Copy link
Owner

You should not tweak hap, to change the minimum temp use something like this in your plugin

this.YourService.getCharacteristic(Characteristic.CurrentTemperature).props.minValue = -50;

I add no issue in this way

@jhubig
Copy link

jhubig commented Nov 22, 2020

You should not tweak hap, to change the minimum temp use something like this in your plugin

OK. Understood.

I have also adapted it in the plugin (homebridge-cmd4\lib\CMD4_ACC_TYPE_ENUM.js). Something I missed?

38:  { type: "CurrentTemperature",
                characteristic: Characteristic.CurrentTemperature,
                props: {format: Characteristic.Formats.FLOAT,
                        unit: Characteristic.Units.CELSIUS,
                        maxValue: 100,
                        minValue: -100,
                        minStep: 0.1,
                        perms: [Characteristic.Perms.READ,
                                Characteristic.Perms.NOTIFY
                               ]
                       },
                validValues: {}
              },

@simont77
Copy link
Owner

As NorthernMan54 said, it seems that the negative values are not passed at all to fakegato. Do you have any means to debug step-by-step?

@NorthernMan54
Copy link
Collaborator

Just put your sensor in the freezer!

F4F24FC3-1D22-4944-9234-57D95BA2B70A

@jhubig
Copy link

jhubig commented Nov 22, 2020

As NorthernMan54 said, it seems that the negative values are not passed at all to fakegato. Do you have any means to debug step-by-step?

I'm currently trying it. Asked also the developer of the homebridge-cmd4 plugin for support. I'll keep you updated. Thanks for your help up to now.

@NorthernMan54: I tried to put the air conditioning system in the freezer. Unfortunately it was too big. 😀

@jhubig
Copy link

jhubig commented Nov 24, 2020

As NorthernMan54 said, it seems that the negative values are not passed at all to fakegato. Do you have any means to debug step-by-step?

I'm currently trying it. Asked also the developer of the homebridge-cmd4 plugin for support. I'll keep you updated. Thanks for your help up to now.

@NorthernMan54: I tried to put the air conditioning system in the freezer. Unfortunately it was too big. 😀

Another stupid question (sorry for that). But how can I find the debug messages from fakegato in the homebridge log. Checked for the fakegato keyword but couldn't find something. Thanks.

image

This is my /etc/default/homebridge:

# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
HOMEBRIDGE_OPTS=-U /var/homebridge -I

# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*
DEBUG=* homebridge -D

@NorthernMan54
Copy link
Collaborator

Fakegato uses the -D option for debug logging and not DEBUG=*

@jhubig
Copy link

jhubig commented Nov 29, 2020

FYI: So as you mentioned already before, it might be the case that the plugin is already sending undefined to fakegato. I will check the plugin-code:

[11/29/2020, 5:50:26 PM] [Cmd4] getValue CurrentTemperature function for:Aussenluft returned:-0.9
[11/29/2020, 5:50:26 PM] [Cmd4] Logging temp:undefined humidity:85 ppm:0
[11/29/2020, 5:50:26 PM] [Cmd4] **Fakegato-timer: addData  Aussenluft { time: 1606668626, temp: undefined, humidity: 85, ppm: 0 }  immediate:  false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants