Simple thing, spent hours to no avail

Hi all. Got hassio working pretty sweet over the past week.

With the daily greeting I wanted to add a few simple commands in the TTS.

Example "today is Monday 18th July, the time is 7am’

Woukd anyone be so kind as to help me do this? I have installed the time and date sensors but I either get 18/07/2018 and 07:00 or nothing. I want to parse the day and date to spoken day, spoken date spoken month’ it’s more foe the kids to learn the days etc.

Seems simple but has me stuffed.
Ty

Ps I am also getting the below random errors in the log

Timer got out of sync. Resetting
01:39 core.py (ERROR)
Error scanning devices
01:38 components/device_tracker/netgear.py (WARNING)
Error talking to API
01:38 /usr/local/lib/python3.6/site-packages/pynetgear/init.py (ERROR)
Timer got out of sync. Resetting
01:36 core.py (ERROR)
Timer got out of sync. Resetting
01:24 core.py (ERROR)
Have some other small issues but first things first

Thanks

The following template should work for you:

{{ strptime(states('sensor.date')~'T'~states('sensor.time'), '%d/%m/%YT%H:%M').strftime('Today is %A %d %B, the time is %I %p') }}

For example, when I do this on the Template Editor page:

{{ strptime(states('sensor.date')~'T'~states('sensor.time'), '%Y-%m-%dT%H:%M').strftime('Today is %A %d %B, the time is %I %p') }}

I get this:

Today is Thursday 19 July, the time is 11 AM

Note that I’m using a slightly different format string in strptime since with my localization the date is printed differently (e.g., ‘2018-07-19’.)

Regarding the errors you’re seeing, I do see “Timer got out of sync. Resetting” from time to time. I don’t know about the netgear device_tracker errors since I’m not using that.

Wow thanks a lot for that i’m going to test it now. Sorry i didnt reply when you sent it, it was 3AM here (australia) will keep you posted how i go

It clears in the template utility but in a script its throwing

"while parsing a block mapping
in “/config/scripts.yaml”, line 61, column 7
expected , but found ‘’
in “/config/scripts.yaml”, line 61, column 48
"

Here is the code in scripts.yaml
(unsure how to post on here in code layout)

153696969696969:
alias: ReadDayDate
sequence:

  • service: tts.google_say
    entity_id: media_player.bedroom_speaker
    data_template:
    message: ‘{{ strptime(states(‘sensor.date’)~‘T’~states(‘sensor.time’), ‘%Y-%m-%dT%H:%M’).strftime(‘Today is %A %B %d’) }}’

hypothetical / not required but a ‘would be nice’ is there any way to add a th or st to the date? ie Today is friday 20th july’ if its too hard or a lot of code dont worry just asking - thanks heaps for what you provided btw

Also any ideas what would be causing this like every few minutes?

Log Details (ERROR)
Fri Jul 20 2018 10:51:26 GMT+1000 (Australian Eastern Standard Time)
Timer got out of sync. Resetting

Can we use an alternate NTP technique to poll time sync because the built in one i think is broken

I think it was the ’ vs " within the brackets, testing now

script:
  my_script:
    service: tts.google_say
    entity_id: media_player.bedroom_speaker
    data_template:
      message: >
        {% set date = strptime(states('sensor.date'), '%d/%m/%Y') %}
        {% set time = strptime(states('sensor.time'), '%H:%M') %}
        {% set day = date.day %}
        {% if day in (1,21,31) %}
          {% set day = day ~ 'st' %}
        {% elif day in (2,22) %}
          {% set day = day ~ 'nd' %}
        {% elif day in (3,23) %}
          {% set day = day ~ 'rd' %}
        {% else %}
          {% set day = day ~ 'th' %}
        {% endif %}
        Today is {{ date.strftime('%A') }} {{ day }} {{
        date.strftime('%B') }}, the time is {{ time.strftime('%I:%M %p') }}

There used to be instructions at the top of the page, but a week or so ago they disappeared for some reason. Basically, select the code and click the </> button.

crap you are good. Thanks so much.
If you are able to help i have a list of things im trying to get working if you have any suggestions?

  1. this is i think a known issue, ive seen it online heaps. Cannot play local mp3 audio in an automation unless you have it in the format “https://xxxxxxx.duckdns.org:8123/local/dadshome.mp3” - i am testing at the moment adding in 192.168.0.119 xxxxx. duck.dns.org into the hosts files in /etc/ (still testing not sure if it will break anything yet)

Here is my trello board of what im trying to do next

I also need to sort out all these time sync errors + stop the “ding” on wake of the google mini’s and stop them going to sleep - but also play a notification without stopping the current music (or resume music after notification)

PS i have a mix of scripts and automations, i really need to standardize things into their own individual scripts…
Heres a chuck from my scripts.yaml (for a laugh or cringe) remember i’m a beginner…

1531882980062:
  alias: Wakeup G Normal
  sequence:
  - service: tts.google_say
    entity_id: media_player.girls
    data_template:
      message: 'Good Morning Penny and Phoebe!. Time to wake up! It is 7AM and you
        have to get up out of bed and ready for school! Todays uniform is your normal
        dress, pretty one. The weather for today is {{states.sensor.weather_hourly_summary.state}}
        Have a wonderful day!'

1531866666062:
  alias: ReadCal
  sequence:
  - service: tts.google_say
    entity_id: media_player.bedroom_speaker
    data_template:
      message: 'You have the following on for today {{states.calendar.ourcalendar007.attributes.message}} at {{ as_timestamp(states.calendar.ourcalendar007.attributes.start_time) | timestamp_custom("%I:%M %p") }}'

153696969696969:
      alias: ReadDayDate
      sequence:
      - service: tts.google_say
        entity_id: media_player.gpmdp
        data_template:
          message: '{{ strptime(states("sensor.date")~"T"~states("sensor.time"), "%Y-%m-%dT%H:%M").strftime("Today is %A %B %d") }}'
  
  
#####################################
#  REALLY great read day date time  #
#####################################

80808080808080:
  alias: DATEDAYTIMEREAD
  sequence:
  - service: tts.google_say
    entity_id: media_player.bedroom_speaker
    data_template:
      message: >
        {% set date = strptime(states('sensor.date'), '%d/%m/%Y') %}
        {% set time = strptime(states('sensor.time'), '%H:%M') %}
        {% set day = date.day %}
        {% if day in (1,21,31) %}
          {% set day = day ~ 'st' %}
        {% elif day in (2,22) %}
          {% set day = day ~ 'nd' %}
        {% elif day in (3,23) %}
          {% set day = day ~ 'rd' %}
        {% else %}
          {% set day = day ~ 'th' %}
        {% endif %}
        Today is {{ date.strftime('%A') }} {{ day }} {{
        date.strftime('%B') }}, the time is {{ time.strftime('%I:%M %p') }}

and a shit tonne of errors im trying to resolve

18-07-21 02:24:09 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:09 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:09 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:11 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:11 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:11 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:13 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:13 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:13 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:15 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:15 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:15 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:17 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:17 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:17 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:19 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:19 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:19 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:21 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:21 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:21 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:23 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:23 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:23 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:25 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:25 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:25 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:27 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:27 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:27 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:29 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:29 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:29 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:31 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:31 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:31 ERROR (MainThread) [hassio.api.proxy] Client error on API stream request Cannot connect to host 172.30.32.1:8123 ssl:None [Connection refused].
18-07-21 02:24:34 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/stream access from a0d7b954_nodered
18-07-21 02:24:34 INFO (MainThread) [hassio.api.proxy] Home-Assistant EventStream start
18-07-21 02:24:36 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/states access from a0d7b954_nodered
18-07-21 02:24:41 INFO (MainThread) [hassio.homeassistant] Detect a running Home-Assistant instance
18-07-21 02:24:44 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/services access from a0d7b954_nodered
18-07-21 02:24:56 INFO (MainThread) [hassio.api.proxy] /homeassistant/api/events access from a0d7b954_nodered

You should post these problems in the correct forum thread.
Since it’s related to the Node-Red add-on, go there: Home Assistant Community Add-on: Node-RED
I posted the same issue there yesterday.

lol! Everything is relative. You’ve already done a shit ton more with HA than I’ll probably ever do! :smile:

I looked over your stuff, and honestly, I really don’t have any experience with most of what you’re trying to do. The only thing that I can think of is my Life360 integration, which works with iOS and Android. It’s the best location service I’ve found and I’ve been using it for years. Yes, it does require a cloud server, and yes their API isn’t formally documented or supported, but it does work and I know many people are using it. If you’re at all interested, check out:

Life360 Device Tracker Platform

Giving zanzito a go at the moment :slight_smile:

wow got more done past few days, now integrating z-wave multisensors the fun part…

1 Like