Ocusim: 'OccuSim' object has no attribute 'turn_on'

ah thats why i didnt get it :wink:
thx for that info

**** Update solved: All times now between " " and no errors. *******

Hi Rene, now working on final app (Occusim) but I get some errors I can’t grab.

Error:

2018-03-26 20:09:45.675113 INFO AppDaemon: Initializing app Occupancy Simulator using class OccuSim from module occusim
2018-03-26 20:09:45.698730 WARNING AppDaemon: ------------------------------------------------------------
2018-03-26 20:09:45.699312 WARNING AppDaemon: Unexpected error running initialize() for Occupancy Simulator
2018-03-26 20:09:45.699771 WARNING AppDaemon: ------------------------------------------------------------
2018-03-26 20:09:45.704447 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1513, in init_object
    init()
  File "/config/appdaemon/apps/occusim.py", line 32, in initialize
    self.create_events({})
  File "/config/appdaemon/apps/occusim.py", line 65, in create_events
    start = self.parse_time(start_p)
  File "/usr/lib/python3.6/site-packages/appdaemon/appapi.py", line 277, in parse_time
    return self.AD.parse_time(time_str, name)
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1015, in parse_time
    parts = re.search('^(\d+):(\d+):(\d+)', time_str)
  File "/usr/lib/python3.6/re.py", line 182, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object

Config:

Occupancy Simulator:
  module: occusim
  class: OccuSim
  log: 1
  notify: 1
  enable: input_boolean.vacation,on
  # test = 1
  dump_times: 1
  reset_time: 02:00:00

  step_morning_name: Morning
  step_morning_start: 06:30:00
  step_morning_end: 08:45:00
  step_morning_on_1: switch.badkamer_licht_255
  step_morning_on_2: scene.sfeer
  step_morning_on_3: scene.kitchen_timer

  step_day_name: Day
  step_day_start: sunrise + 00:15:00
  step_day_off_1: switch.badkamer_licht_255
  step_day_off_2: scene.sfeer_off
  step_day_off_3: scene.kitchen_timer_off

  step_evening_name: Evening
  step_evening_start: sunset - 00:45:00
  step_evening_on_1: scene.sfeer
  step_evening_on_2: switch.greenwave_powernode_1_port_switch_31_0

  step_night_name: Night
  step_night_start: 22:30:00 
  step_night_end: 23:30:00
  step_night_on_1: scene.sleeptime
  step_night_on_2: light.trappenhuis_24
  step_night_on_3: switch.badkamer_licht_255
  step_night_on_4: light.slaapkamer_ouders_177

  step_upstairs_hall_name: Upstairs Hall Off
  step_upstairs_hall_relative: Night
  step_upstairs_hall_start_offset: 00:01:00
  step_upstairs_hall_end_offset: 00:10:00
  step_upstairs_hall_off_1: light.trappenhuis_24
  step_upstairs_hall_off_2: switch.badkamer_licht_255

  step_lightsout_name: Lights Out
  step_lightsout_relative: Night
  step_lightsout_start_offset: 00:01:00
  step_lightsout_end_offset: 00:20:00
  step_lightsout_off_1: light.slaapkamer_ouders_177

  random_toilet_name: Evening toilet
  random_toilet_start: Evening
  random_toilet_end: Night
  random_toilet_minduration: 00:03:00
  random_toilet_maxduration: 00:05:00
  random_toilet_number: '3'
  random_toilet_on_1: light.licht_toilet_176
  random_toilet_off_1: light.licht_toilet_176

  random_kitchen_name: Evening kitchen
  random_kitchen_start: Evening
  random_kitchen_end: Night
  random_kitchen_minduration: 00:02:00
  random_kitchen_maxduration: 00:10:00
  random_kitchen_number: '5'
  random_kitchen_on_1: scene.kitchen_timer
  random_kitchen_off_1: scene.kitchen_timer_off

  random_attic_name: Evening attic
  random_attic_start: Evening
  random_attic_end: Lights Out
  random_attic_minduration: 00:02:00
  random_attic_maxduration: 00:05:00
  random_attic_number: '3'
  random_attic_on_1: switch.qubino_zmnhbdx_flush_2_relays_switch_12_0_2
  random_attic_off_1: switch.qubino_zmnhbdx_flush_2_relays_switch_12_0_2

The Ocusim app is identical to this post

My first thinking was a YAML formatting thing for the times but formatting is identical then this post so I doubt its a formatting (times between quotes etc).

Any idea?

Hi Rene,

All working fine now altough I have an error in the logs. It does not seem to effect Appdeamon but if I can get rid of it, I would be happy.

Error:

2018-03-26 20:25:20.374506 WARNING AppDaemon: ------------------------------------------------------------
2018-03-26 20:25:20.375410 WARNING AppDaemon: Unexpected error loading config file: /config/appdaemon/apps/._apps.yaml
2018-03-26 20:25:20.376831 WARNING AppDaemon: ------------------------------------------------------------
2018-03-26 20:25:20.379451 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1609, in read_config_file
    config_file_contents = yamlfd.read()
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 37: invalid start byte

somehow this temperary file is created and bugging you:

/config/appdaemon/apps/._apps.yaml

delete that.

Thanks for your examples.

I get this error (but occusim works as expected):

File “/usr/lib/python3.6/site-packages/appdaemon/appdaemon.py”, line 1677, in read_config_file
config_file_contents = yamlfd.read()
File “/usr/lib/python3.6/codecs.py”, line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xb0 in position 37: invalid start byte

It’s a little offtopic, but could someone explain how “notify” works with this.
Where does it send the notification and which information?

you got a character in your yaml thats not unicode.
this happens when you edit with an editor that doesnt translate characters the right way, when saving and you use non unicode characters.

so

  • start using an other editor or
  • dont use characters that are not utf-8

about your second question.
the notify sends notifications to 1 of your notification platforms (or all) inside HA.
what and when it sends depends on your settings.
if i remember correctly you need to configure your notify settings in the file global.py

UTF-8
I use virtual studio code on a mac. In the lower right corner I can see a UTF-8 label. It looks like all of my files I changed in appdeamon are UTF-8. Is there a way to point out symbols that are not UTF-8?

notify:
Where can I find the global.py file? I use hass.io, so don’t know I I could change that.
But it seems like not many of use use notify in occusim. I don’t know yet if I want to use it or if I notify myself with an automation (when input_boolean is turned on)

i dont know what in your yaml is creating the error. could be tab sign, or something like ä, Ë, ó or a grad sign.

i was mistaken about the notify (was thinking about some other apps,sorry)
the notify sends messages to every notify platform you have created in home assistant.

and the readme says:

  • notify set this to any value to make OccuSim send a notification for its scheduled activities

I reed the readme and still don’t get how it works, as firing all notify platforms males no sense for me.

However I ran into another issue.

I had to '' all of my time values so instead of 00:00:00 I had to use '00:00:00'

How can I use sunset with this

'sunset + 00:30:00'

and

sunset + '00:30:00'

did not work

yaml interprets times as datetime objects.
thats why you need to use quotes (i prefer double quotes ") around a time
sunset is already a string, so leave the quotes there away.

if you dont want a notify to all your notify platforms then dont use that option.

Is there a reason why you prefer doubles quotes? I was never sure about which ones I should use. I think I did not use it consistently in my whole config.

So sunset + 00:30:00 should be fine.

There is still the question why I get this error (utf-8).
I commented out the whole code I put in and I still get that error.
I use the newest version of ha 0.86.1 and the newest appdeamon addon.
Maybe a new bug?

like you i never was sure. and i think its hard sometimes.
my prefference comes from the old days i guess.
in general just pick 1 as your main quote type and only use the other when you need to (quotes in quotes)

i think so.

the bug is somewhere in the yaml from appdaemon (or else you wouldnt get an error in the appdaemon logs)
and there have not been any changes in appdaemon for a long time, so it cant be a new bug :wink:

it can be a tab on an empty line for instance.
try another editor. try a yaml checker online. there must be a character somewhere in your yaml files that gives you that error.
but it can be in ANY yaml file that you got inside your apps dir

yes, this worked.

I also got rid of the error, was something in my apps.yaml. Thanks

1 Like