michbeck100 / pimatic-hap

Pimatic homekit bridge
GNU General Public License v2.0
30 stars 10 forks source link

pimatic-log-reader integration #42

Closed hg-smart closed 7 years ago

hg-smart commented 7 years ago

hello i am using pimatic-logreader to read the temperature from an external sensor (logfile)

pimatic-log-reader

 {
      "plugin": "log-reader"
 },
{
      "id": "temperature-from-logfile-bad-h1",
      "name": "Bad Temperatur",
      "class": "LogWatcher",
      "file": "/home/pi/log/aa_t.log",
      "attributes": [
        {
          "name": "temperature",
          "type": "number",
          "unit": "°C"
        }
      ],
      "lines": [
        {
          "match": "temperature: (.+)",
          "temperature": "$1"
        }
      ]
    },

Is it possible to integrate this into pimatic-hap ? Could you give me any hints where to pay attention, please.

Thx in advance hans

michbeck100 commented 7 years ago

I'll have a look. Generally just 'real' temperature sensors are currently supported.

hg-smart commented 7 years ago

cool, for testing you could simple create a file with the follwing contents, thx a lot hans

pi@raspberrypi:~ $ cat /home/pi/log/aa_t.log
temperature: 20.9
michbeck100 commented 7 years ago

I'm sorry but the log-reader plugin is too "flexible" to integrate it into pimatic-hap. pimatic-hap relies on well-defined interfaces (although well-defined is an elastic term in the JavaScript world).

michbeck100 commented 7 years ago

I'm reopening this, since the implementation will be the same as for https://github.com/michbeck100/pimatic-hap/issues/51

michbeck100 commented 7 years ago

https://github.com/michbeck100/pimatic-hap/commit/da2c11e2ae64665c03976eb6913c88631757c35f implements a new generic sensor that currently supports temperature and humidity. Note that these attributes are case sensitive. I did test with the same device example you provided. The new sensor will be included in the next release.