fhem / LuftdatenInfo

provides data from Luftdaten.info
GNU General Public License v2.0
0 stars 1 forks source link

Slave device gets no data #63

Open christoph-morrison opened 3 years ago

christoph-morrison commented 3 years ago

A slave device gets no data, even it's a copy from another slave device and the master is getting data.

Master:

Internals:
   .FhemMetaInternals 1
   ADDRESS    feinstaubsensor.fritz.box
   DEF        local feinstaubsensor.fritz.box
   FUUID      5fbd797f-f33f-0f53-b10d-f1c15edb0345c39d
   FVERSION   59_LuftdatenInfo.pm:0.219370/2020-05-14
   INTERVAL   60
   MODE       local
   NAME       out.sensors.environment.6
   NR         9267
   STATE      device_alive
rssi_bad
   TIMEOUT    5
   TYPE       LuftdatenInfo
   .attraggr:
   .attrminint:
   .userReadings:
     HASH(0x55f5975eb198)
     HASH(0x55f5975eca38)
   Helper:
     DBLOG:
       activity:
         general.system.log.db:
           TIME       1606311878.96102
           VALUE      alive
       date:
         general.system.log.db:
           TIME       1606311878.96102
           VALUE      24.11.2020
       max_micro:
         general.system.log.db:
           TIME       1606311878.96102
           VALUE      379056
       min_micro:
         general.system.log.db:
           TIME       1606311878.96102
           VALUE      398
       rssi_quality:
         general.system.log.db:
           TIME       1606311878.96102
           VALUE      rssi_bad
       samples:
         general.system.log.db:
           TIME       1606311878.96102
           VALUE      1747075
       signal:
         general.system.log.db:
           TIME       1606311878.96102
           VALUE      -86
       softwareVersion:
         general.system.log.db:
           TIME       1606311518.72106
           VALUE      NRZ-2018-111-AF-070
       state:
         general.system.log.db:
           TIME       1606311878.96102
           VALUE      active
       time:
         general.system.log.db:
           TIME       1606311878.96102
           VALUE      21:52:10
   READINGS:
     2020-11-25 14:38:38   .sensors        BME680_air_quality BME680_humidity BME680_pressure BME680_pressure_nn BME680_quality_data BME680_temperature DHT22_humidity DHT22_temperature SDS011_P1 SDS011_P2 max_micro min_micro samples sensor_start_date sensor_start_time signal
     2020-11-25 14:44:38   activity        alive
     2020-11-25 14:44:38   activity_state  device_alive
     2020-11-25 14:44:38   date            24.11.2020
     2020-11-25 14:44:38   max_micro       379056
     2020-11-25 14:44:38   min_micro       398
     2020-11-25 14:44:38   rssi_quality    rssi_bad
     2020-11-25 14:44:38   samples         1747075
     2020-11-25 14:44:38   signal          -86
     2020-11-25 14:38:38   softwareVersion NRZ-2018-111-AF-070
     2020-11-25 14:44:38   state           active
     2020-11-25 14:44:38   time            21:52:10
Attributes:
   alias      Feinstaubsensor Tulpenweg / Nelkenweg
   devStateIcon rssi_good:it_wifi@42BC0A rssi_medium:it_wifi@sandybrown rssi_bad:it_wifi@E50005 rssi_check:unknown@gray 
device_alive:device_alive@42BC0A device_dead:device_dead@E50005
   group      Feinstaubsensor Tulpenweg / Nelkenweg
   icon       air-pollution@black
   interval   60
   rawReading 1
   room       Außen->Sensoren->Umwelt
   sortby     100
   stateFormat activity_state
rssi_quality
   userReadings activity {
    return (ReadingsVal($name, q(state), q(error)) eq q(active))
        ? q(alive)
        : q(dead);
},
rssi_quality:signal:.+ {\
    return FHEM::MyUtils::Readings::rssi_quality($name, q(signal));
},

Slave (with data):

Internals:
   .FhemMetaInternals 1
   DEF        slave 
out.sensors.environment.6
SDS011_P1 SDS011_P2
   FUUID      5fbd8db3-f33f-0f53-ba6e-f68164122851768e
   FVERSION   59_LuftdatenInfo.pm:0.219370/2020-05-14
   MASTER     out.sensors.environment.6
   MODE       slave
   NAME       out.sensors.environment.6.sds011
   NR         9270
   SENSORS    SDS011_P1 SDS011_P2
   STATE      device_alive
   TYPE       LuftdatenInfo
   .attraggr:
   .attrminint:
   .userReadings:
     HASH(0x55f5975edd50)
   Helper:
     DBLOG:
       PM10:
         general.system.log.db:
           TIME       1606311170.10616
           VALUE      13.35
       PM2.5:
         general.system.log.db:
           TIME       1606311170.10616
           VALUE      9.88
       activity:
         general.system.log.db:
           TIME       1606311170.10616
           VALUE      alive
       state:
         general.system.log.db:
           TIME       1606311170.10616
           VALUE      active
   READINGS:
     2020-11-25 14:32:49   PM10            13.35
     2020-11-25 14:32:49   PM2.5           9.88
     2020-11-25 14:32:50   activity        alive
     2020-11-25 14:32:50   activity_state  device_alive
     2020-11-25 14:32:49   state           active
Attributes:
   alias      Feinstaubsensor Tulpenweg / Nelkenweg - SDS011
   group      Feinstaubsensor Tulpenweg / Nelkenweg
   icon       circuit@black
   rawReading 1
   room       Außen->Sensoren->Umwelt
   sortby     130
   stateFormat activity_state
   userReadings activity {
    return (ReadingsVal($name, q(state), q(error)) eq q(active))
        ? q(alive)
        : q(dead);
},

Slave (no data):

Internals:
   CFGFN      
   DEF        slave 
out.sensors.environment.6
SDS011_P1
   FUUID      5fbe5d8d-f33f-0f53-7c98-011fc0a78ec83a43
   MASTER     out.sensors.environment.6
   MODE       slave
   NAME       out.sensors.environment.6.sds011.pm10
   NR         22547
   SENSORS    SDS011_P1
   STATE      active
   TYPE       LuftdatenInfo
   .attraggr:
   .attrminint:
   Helper:
     DBLOG:
       state:
         general.system.log.db:
           TIME       1606312059.10391
           VALUE      active
   READINGS:
     2020-11-25 14:47:38   state           active
Attributes:
   rawReading 1

defmoding the slave without data didn't help, also didn`t renaming it.

christoph-morrison commented 3 years ago

See also the missing FVERSION (and other) internal.

Igami commented 3 years ago

https://github.com/fhem/LuftdatenInfo/blob/90f0d2011760e37075292db627c0ab521d29426c/FHEM/59_LuftdatenInfo.pm#L428-L430

It is not intended that the same sensor is displayed in several devices. The slave sensors are not displayed in the master device. This follows the principle that a source generates only one event in the FHEM. If more than one device is needed, this can be derived with readingsProxy.

Now there are two possibilities.

  1. omit readingsProxy and add a similar functionality to LuftdatenInfo
  2. check in the define whether a device with the same sensor already exists and display an error message

I would prefer the second option.

christoph-morrison commented 3 years ago

I didn't know about that principle and there is at least one module that does not follow this principle (HMCCU). I would expect the module to behave in such a way that I can define any devices that can combine any selection of sensors of a master device and can also multiply sensors if I as a user wish so.

A workaround for using LuftdatenInfo with local sensors alltogether is using JSONMOD, e.g. for a SDS011_P1 value the following JsonPath expression will receive the dust sensor PM10 value: $.sensordatavalues.[?(@.value_type == 'SDS011_P1')].value