Trying to integrate Fibaro motion sensor in HA

420 views
Skip to first unread message

mbart...@gmail.com

unread,
Jun 10, 2015, 10:08:41 AM6/10/15
to home-assi...@googlegroups.com
Hey All,

I am trying to get a Fibaro multi sensor to play nice in HA and getting lost on how the data gets serviced.

I have found when motion is detected by the sensor, a NodeEvent event message is sent. A value of 255 indicates motion and 0 if no motion is detected within a 8 second or so window.

I added this callback code to the ZWaveSensor class:

    def _node_event(self, **kwargs):
        """ Called when a node event (i.e. motion sensor) is generated"""
        self._value.data = False if kwargs['value'] == '0' else True
        self.update_ha_state() 

This does update the state and triggers a call to the state method in the ZWaveBinarySensor class as expected. The problem is with the data. Apparently somewhere self._value.data is overwritten as it always reports a value of False. I even tried forcing it True, but again False was reported. 

Log info:

2015-06-10 09:40:04.635 Detail, Node005,   Received: 0x01, 0x09, 0x00, 0x04, 0x00, 0x05, 0x03, 0x20, 0x01, 0xff, 0x2a
2015-06-10 09:40:04.635 Detail, 
2015-06-10 09:40:04.635 Info, Node005, Received Basic set from node 5: level=255.  Sending event notification.
>>>>>>>>> binary sensor self._value.data = False
INFO:homeassistant:Bus:Handling <Event state_changed[L]: old_state=<state sensor.fibaro_system_unknown_type0800_id2001_sensor=off; friendly_name=FIBARO System Unknown: type=0800, id=2001 Sensor, node_id=5 @ 09:39:22 10-06-2015>, entity_id=sensor.fibaro_system_unknown_type0800_id2001_sensor, new_state=<state sensor.fibaro_system_unknown_type0800_id2001_sensor=off; friendly_name=FIBARO System Unknown: type=0800, id=2001 Sensor, node_id=5, battery_level=92 @ 09:39:22 10-06-2015>>
>>>> Multilevel value: 0.0
INFO:homeassistant:Bus:Handling <Event state_changed[L]: old_state=<state sensor.fibaro_system_unknown_type0800_id2001_temperature=0.0; friendly_name=FIBARO System Unknown: type=0800, id=2001 Temperature, node_id=5 @ 09:39:22 10-06-2015>, entity_id=sensor.fibaro_system_unknown_type0800_id2001_temperature, new_state=<state sensor.fibaro_system_unknown_type0800_id2001_temperature=0.0; friendly_name=FIBARO System Unknown: type=0800, id=2001 Temperature, node_id=5, battery_level=92 @ 09:39:22 10-06-2015>>
>>>> Multilevel value: 0.0
INFO:homeassistant:Bus:Handling <Event state_changed[L]: old_state=<state sensor.fibaro_system_unknown_type0800_id2001_luminance=0.0; friendly_name=FIBARO System Unknown: type=0800, id=2001 Luminance, node_id=5 @ 09:39:22 10-06-2015>, entity_id=sensor.fibaro_system_unknown_type0800_id2001_luminance, new_state=<state sensor.fibaro_system_unknown_type0800_id2001_luminance=0.0; friendly_name=FIBARO System Unknown: type=0800, id=2001 Luminance, node_id=5, battery_level=92 @ 09:39:22 10-06-2015>>

SIGNAL ***** NodeEvent



2015-06-10 09:40:35.362 Detail, Node005,   Received: 0x01, 0x09, 0x00, 0x04, 0x00, 0x05, 0x03, 0x20, 0x01, 0x00, 0xd5
2015-06-10 09:40:35.363 Detail, 
2015-06-10 09:40:35.363 Info, Node005, Received Basic set from node 5: level=0.  Sending event notification.
>>>>>>>>> binary sensor self._value.data = False

Temperature and luminance is always reports 0, but that is yet another issue to be resolved.

Any help or guidance is appreciated,
Mark


Paulus Schoutsen

unread,
Jun 11, 2015, 4:06:25 AM6/11/15
to home-assi...@googlegroups.com
the _value attribute is a Z-Wave value that is kept up to date by the network and should not be set directly unless you want to write that value. For sensors I don't think the values are writable.

I would suggest to create a new class, ZWaveMotionDetectorSensor, that sets the state based on events instead of using Z-Wave values.

--
You received this message because you are subscribed to the Google Groups "Home Assistant Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to home-assistant-...@googlegroups.com.
To post to this group, send email to home-assi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/home-assistant-dev/256ab10d-6fab-41d1-893b-82b1387aef07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
It's nice to be important but it's more important to be nice.

mbart...@gmail.com

unread,
Jun 11, 2015, 2:49:53 PM6/11/15
to home-assi...@googlegroups.com
Hi Paulus,
Well I am closer now. I added a new class per your suggestion. I am now getting motion events and I am able to see the sensor switch from off to on and back on the web page.

got state in ZWaveMotionDetectorSensor
INFO:homeassistant:Bus:Handling <Event state_changed[L]: old_state=<state sensor.fibaro_system_unknown_type0800_id2001_sensor_2=off; friendly_name=FIBARO System Unknown: type=0800, id=2001 Sensor, node_id=5, battery_level=92 @ 14:31:40 11-06-2015>, new_state=<state sensor.fibaro_system_unknown_type0800_id2001_sensor_2=on; friendly_name=FIBARO System Unknown: type=0800, id=2001 Sensor, node_id=5, battery_level=92 @ 14:32:05 11-06-2015>, entity_id=sensor.fibaro_system_unknown_type0800_id2001_sensor_2>

I still have a couple of issues though. There are two sensors that is created, one is from my class and the other is from the binary switch class. I suppose the one from the binary sensor class could be hidden, but I have not idea if that will cause issues down the road. Probably more confusion that anything else. 

The second problem is that I am not able to cause a trigger to occur base on the sensor state.  From my config file:

notify:
  platform: demo

automation:
  platform: state
  state_entity_id: sensor.fibaro_system_unknown_type0800_id2001_sensor_2
  state_from: off
  state_to: on
  execute_service: notify.notify 

I must be still missing something somewhere is setting state.

Thoughts?

Thanks
Mark

Paulus Schoutsen

unread,
Jun 11, 2015, 3:54:35 PM6/11/15
to home-assi...@googlegroups.com
Have a look at the first example of the documentation, you're missing the service_data for the notify service call.

--
You received this message because you are subscribed to the Google Groups "Home Assistant Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to home-assistant-...@googlegroups.com.
To post to this group, send email to home-assi...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

mbart...@gmail.com

unread,
Jun 11, 2015, 6:20:35 PM6/11/15
to home-assi...@googlegroups.com
Paulus,
Unfortunately that did not help. I did not put a service message in since all I was looking for was a log message that the notify event took place. I did verify this was working by setting up a simple time event for the notify message.

I noticed there was no log message that the automation rule was executed when I sent a motion event compared to what the time event displayed.

From my motion sensor class:

class ZWaveMotionDetectorSensor(Entity):
    def __init__(self, sensor_value):
        self._value = sensor_value
        self._node = sensor_value.node
        self._motion_detect_level = 0            
        dispatcher.connect(
            self._node_event, ZWaveNetwork.SIGNAL_NODE_EVENT)

    @property        
    def state(self):
        print ('got state in ZWaveMotionDetectorSensor')
        return STATE_ON if self._motion_detect_level else STATE_OFF

    def _node_event(self, **kwargs):
        """ Called when a node event (i.e. motion sensor) is generated"""
        self._motion_detect_level = kwargs['value']
        print ('------>>>>>motion sensor level value: {}'. format(self._motion_detect_level))
        self.update_ha_state() 

I wasn't sure the best way to handle the generating the unique id, so for now I just tacked on a constant to what you had for the other sensor class,
    @property
    def unique_id(self):
        """ Returns a unique id. """        
        return "ZWAVE-{}-{}".format(self._node.node_id, 12345)


Thanks
Mark


On Wednesday, June 10, 2015 at 10:08:41 AM UTC-4, mbart...@gmail.com wrote:

Paulus Schoutsen

unread,
Jun 12, 2015, 2:13:17 AM6/12/15
to home-assi...@googlegroups.com
Try using the dev tools in the interface to trigger the automation, the one in the middle. You should be able to trigger state changes manually.

Paulus

--
You received this message because you are subscribed to the Google Groups "Home Assistant Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to home-assistant-...@googlegroups.com.
To post to this group, send email to home-assi...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

mbart...@gmail.com

unread,
Jun 12, 2015, 5:50:15 AM6/12/15
to home-assi...@googlegroups.com
I'm getting the same result when I change the state manually.  The log show a motion event, but does not trigger an automation rule. Do you think it is somehow related to the creation of two separate sensors, one for the binary sensor class and one for my new class? They do have separate entity ID's.  A _2 is tacked on the one that created with my new class.

Mark
 

On Wednesday, June 10, 2015 at 10:08:41 AM UTC-4, mbart...@gmail.com wrote:

Paulus Schoutsen

unread,
Jun 12, 2015, 11:02:46 AM6/12/15
to home-assi...@googlegroups.com

It must be something with your rule. Is there any warning in your log file?


--
You received this message because you are subscribed to the Google Groups "Home Assistant Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to home-assistant-...@googlegroups.com.
To post to this group, send email to home-assi...@googlegroups.com.

mbart...@gmail.com

unread,
Jun 12, 2015, 1:07:07 PM6/12/15
to home-assi...@googlegroups.com
No warnings in the log. I did get it to work by quoting the off and on settings for state_from and state_ to config value. For some reason the config.get calls were returning True and False if I did not explicitly add the quotes.

Anyway it seems to be working. I will continue to do some testing and will try to figure out the temperature and luminance issue.

Thanks for the help
Mark

On Wednesday, June 10, 2015 at 10:08:41 AM UTC-4, mbart...@gmail.com wrote:

Paulus Schoutsen

unread,
Jun 12, 2015, 1:32:12 PM6/12/15
to home-assi...@googlegroups.com
Oooh, yes, it's the magic performed by the YAML parser. It is 'smart' and translates 1, on, true, 0, off, false to booleans. We should update this in the documentation.

Paulus

--
You received this message because you are subscribed to the Google Groups "Home Assistant Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to home-assistant-...@googlegroups.com.
To post to this group, send email to home-assi...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages